|
216 | 216 | //! };
|
217 | 217 | //!
|
218 | 218 | //! for byte in b"Hello, world!" {
|
219 |
| -//! // NOTE `block!` blocks until `serial.write()` completes and returns |
| 219 | +//! // NOTE `block!` blocks until `serial.try_write()` completes and returns |
220 | 220 | //! // `Result<(), Error>`
|
221 |
| -//! block!(serial.write(*byte)).unwrap(); |
| 221 | +//! block!(serial.try_write(*byte)).unwrap(); |
222 | 222 | //! }
|
223 | 223 | //! # }
|
224 | 224 | //!
|
225 | 225 | //! # mod stm32f30x_hal {
|
226 | 226 | //! # use std::convert::Infallible;
|
227 | 227 | //! # pub struct Serial1;
|
228 | 228 | //! # impl Serial1 {
|
229 |
| -//! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Infallible> { |
| 229 | +//! # pub fn try_write(&mut self, _: u8) -> ::nb::Result<(), Infallible> { |
230 | 230 | //! # Ok(())
|
231 | 231 | //! # }
|
232 | 232 | //! # }
|
|
419 | 419 | //! loop {
|
420 | 420 | //! // `await!` means "suspend / yield here" instead of "block until
|
421 | 421 | //! // completion"
|
422 |
| -//! nb::r#await!(timer.wait()).unwrap(); // NOTE(unwrap) E = Infallible |
| 422 | +//! nb::r#await!(timer.try_wait()).unwrap(); // NOTE(unwrap) E = Infallible |
423 | 423 | //!
|
424 | 424 | //! state = !state;
|
425 | 425 | //!
|
|
433 | 433 | //!
|
434 | 434 | //! let mut loopback = (move || {
|
435 | 435 | //! loop {
|
436 |
| -//! let byte = nb::r#await!(serial.read()).unwrap(); |
437 |
| -//! nb::r#await!(serial.write(byte)).unwrap(); |
| 436 | +//! let byte = nb::r#await!(serial.try_read()).unwrap(); |
| 437 | +//! nb::r#await!(serial.try_write(byte)).unwrap(); |
438 | 438 | //! }
|
439 | 439 | //! });
|
440 | 440 | //!
|
|
450 | 450 | //! # use std::convert::Infallible;
|
451 | 451 | //! # pub struct Serial1;
|
452 | 452 | //! # impl Serial1 {
|
453 |
| -//! # pub fn read(&mut self) -> ::nb::Result<u8, Infallible> { Err(::nb::Error::WouldBlock) } |
454 |
| -//! # pub fn write(&mut self, _: u8) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
| 453 | +//! # pub fn try_read(&mut self) -> ::nb::Result<u8, Infallible> { Err(::nb::Error::WouldBlock) } |
| 454 | +//! # pub fn try_write(&mut self, _: u8) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
455 | 455 | //! # }
|
456 | 456 | //! # pub struct Timer6;
|
457 | 457 | //! # impl Timer6 {
|
458 |
| -//! # pub fn wait(&mut self) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
| 458 | +//! # pub fn try_wait(&mut self) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
459 | 459 | //! # }
|
460 | 460 | //! # pub struct Led;
|
461 | 461 | //! # impl Led {
|
|
0 commit comments