|
75 | 75 | //! type Error;
|
76 | 76 | //!
|
77 | 77 | //! /// Reads a single byte
|
78 |
| -//! fn read(&mut self) -> nb::Result<u8, Self::Error>; |
| 78 | +//! fn try_read(&mut self) -> nb::Result<u8, Self::Error>; |
79 | 79 | //!
|
80 | 80 | //! /// Writes a single byte
|
81 |
| -//! fn write(&mut self, byte: u8) -> nb::Result<(), Self::Error>; |
| 81 | +//! fn try_write(&mut self, byte: u8) -> nb::Result<(), Self::Error>; |
82 | 82 | //! }
|
83 | 83 | //! ```
|
84 | 84 | //!
|
|
150 | 150 | //! impl hal::serial::Read<u8> for Serial<USART1> {
|
151 | 151 | //! type Error = Error;
|
152 | 152 | //!
|
153 |
| -//! fn read(&mut self) -> nb::Result<u8, Error> { |
| 153 | +//! fn try_read(&mut self) -> nb::Result<u8, Error> { |
154 | 154 | //! // read the status register
|
155 | 155 | //! let isr = self.usart.isr.read();
|
156 | 156 | //!
|
|
172 | 172 | //! impl hal::serial::Write<u8> for Serial<USART1> {
|
173 | 173 | //! type Error = Error;
|
174 | 174 | //!
|
175 |
| -//! fn write(&mut self, byte: u8) -> nb::Result<(), Error> { |
176 |
| -//! // Similar to the `read` implementation |
| 175 | +//! fn try_write(&mut self, byte: u8) -> nb::Result<(), Error> { |
| 176 | +//! // Similar to the `try_read` implementation |
177 | 177 | //! # Ok(())
|
178 | 178 | //! }
|
179 | 179 | //!
|
180 |
| -//! fn flush(&mut self) -> nb::Result<(), Error> { |
181 |
| -//! // Similar to the `read` implementation |
| 180 | +//! fn try_flush(&mut self) -> nb::Result<(), Error> { |
| 181 | +//! // Similar to the `try_read` implementation |
182 | 182 | //! # Ok(())
|
183 | 183 | //! }
|
184 | 184 | //! }
|
|
281 | 281 | //! {
|
282 | 282 | //! let mut serial = Some(serial);
|
283 | 283 | //! future::poll_fn(move || {
|
284 |
| -//! let byte = try_nb!(serial.as_mut().unwrap().read()); |
| 284 | +//! let byte = try_nb!(serial.as_mut().unwrap().try_read()); |
285 | 285 | //!
|
286 | 286 | //! Ok(Async::Ready((serial.take().unwrap(), byte)))
|
287 | 287 | //! })
|
|
296 | 296 | //! {
|
297 | 297 | //! let mut serial = Some(serial);
|
298 | 298 | //! future::poll_fn(move || {
|
299 |
| -//! try_nb!(serial.as_mut().unwrap().write(byte)); |
| 299 | +//! try_nb!(serial.as_mut().unwrap().try_write(byte)); |
300 | 300 | //!
|
301 | 301 | //! Ok(Async::Ready(serial.take().unwrap()))
|
302 | 302 | //! })
|
|
361 | 361 | //! # pub struct Serial1;
|
362 | 362 | //! # impl ::hal::serial::Read<u8> for Serial1 {
|
363 | 363 | //! # type Error = Infallible;
|
364 |
| -//! # fn read(&mut self) -> ::nb::Result<u8, Infallible> { Err(::nb::Error::WouldBlock) } |
| 364 | +//! # fn try_read(&mut self) -> ::nb::Result<u8, Infallible> { Err(::nb::Error::WouldBlock) } |
365 | 365 | //! # }
|
366 | 366 | //! # impl ::hal::serial::Write<u8> for Serial1 {
|
367 | 367 | //! # type Error = Infallible;
|
368 |
| -//! # fn flush(&mut self) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
369 |
| -//! # fn write(&mut self, _: u8) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
| 368 | +//! # fn try_flush(&mut self) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
| 369 | +//! # fn try_write(&mut self, _: u8) -> ::nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
370 | 370 | //! # }
|
371 | 371 | //! #
|
372 | 372 | //! # pub struct Led;
|
|
492 | 492 | //! S: hal::serial::Write<u8>
|
493 | 493 | //! {
|
494 | 494 | //! for &byte in buffer {
|
495 |
| -//! block!(serial.write(byte))?; |
| 495 | +//! block!(serial.try_write(byte))?; |
496 | 496 | //! }
|
497 | 497 | //!
|
498 | 498 | //! Ok(())
|
|
528 | 528 | //! timer.try_start(timeout).map_err(Error::TimedOut)?;
|
529 | 529 | //!
|
530 | 530 | //! loop {
|
531 |
| -//! match serial.read() { |
| 531 | +//! match serial.try_read() { |
532 | 532 | //! // raise error
|
533 | 533 | //! Err(nb::Error::Other(e)) => return Err(Error::Serial(e)),
|
534 | 534 | //! Err(nb::Error::WouldBlock) => {
|
|
608 | 608 | //! {
|
609 | 609 | //! loop {
|
610 | 610 | //! if let Some(byte) = cb.peek() {
|
611 |
| -//! match serial.write(*byte) { |
| 611 | +//! match serial.try_write(*byte) { |
612 | 612 | //! Err(nb::Error::Other(_)) => unreachable!(),
|
613 | 613 | //! Err(nb::Error::WouldBlock) => return,
|
614 | 614 | //! Ok(()) => {}, // keep flushing data
|
|
670 | 670 | //! # struct Serial1;
|
671 | 671 | //! # impl ::hal::serial::Write<u8> for Serial1 {
|
672 | 672 | //! # type Error = Infallible;
|
673 |
| -//! # fn write(&mut self, _: u8) -> nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
674 |
| -//! # fn flush(&mut self) -> nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
| 673 | +//! # fn try_write(&mut self, _: u8) -> nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
| 674 | +//! # fn try_flush(&mut self) -> nb::Result<(), Infallible> { Err(::nb::Error::WouldBlock) } |
675 | 675 | //! # }
|
676 | 676 | //! # struct CircularBuffer;
|
677 | 677 | //! # impl CircularBuffer {
|
|
0 commit comments