SerialWrap

Struct SerialWrap 

Source
pub struct SerialWrap<T>
where T: SerialPort,
{ /* private fields */ }
Expand description

Implment the traits required for a FramedConnection based on a serial::SerialPort.

Note that the async processing of FramedConnection depends on a short timeout being set. At the time of writing, serial::open() returned a SerialPort with a default of 100 msec.

Implementations§

Source§

impl<T> SerialWrap<T>
where T: SerialPort,

Source

pub fn new(port: T) -> SerialWrap<T>

Constructor

Trait Implementations§

Source§

impl<T> MutNonBlockingRx for SerialWrap<T>
where T: SerialPort,

Source§

type Error = Error

The error type returned if getc fails.
Source§

fn getc_try(&mut self) -> Result<Option<u8>, Self::Error>

Attempt to read a single octet from the port’s receiver; if the buffer is empty return None. Read more
Source§

fn gets_try<I>(&mut self, buffer: &mut I) -> Result<usize, (usize, Self::Error)>
where I: AsMut<[u8]> + ?Sized,

Read a specified number of octets into the given buffer, or until the data runs out. Read more
Source§

impl<T> MutNonBlockingTx for SerialWrap<T>
where T: SerialPort,

Source§

fn putc_try(&mut self, ch: u8) -> Result<Option<u8>, Self::Error>

Try and write a single octet to the port’s transmitter. Will return Ok(None) if the FIFO/buffer was full and the octet couldn’t be stored or Ok(Some(ch)) if it was stored OK.

In some implementations, this can result in an Error. If not, use type Error = !.

Source§

type Error = Error

The error type returned if function fails.
Source§

fn puts_try<I>(&mut self, data: &I) -> Result<usize, (usize, Self::Error)>
where I: AsRef<[u8]> + ?Sized,

Write as much of a complete string to the UART as possible. Returns the number of octets sent, plus the result from the last putc call. Aborts early if putc fails in any way.

Auto Trait Implementations§

§

impl<T> Freeze for SerialWrap<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SerialWrap<T>
where T: RefUnwindSafe,

§

impl<T> Send for SerialWrap<T>
where T: Send,

§

impl<T> Sync for SerialWrap<T>
where T: Sync,

§

impl<T> Unpin for SerialWrap<T>
where T: Unpin,

§

impl<T> UnwindSafe for SerialWrap<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.