Trait MutBlockingRxWithTimeout

Source
pub trait MutBlockingRxWithTimeout {
    type Timeout;
    type Error;

    // Required method
    fn getc_wait(
        &mut self,
        timeout: &Self::Timeout,
    ) -> Result<Option<u8>, Self::Error>;

    // Provided method
    fn gets_wait<I>(
        &mut self,
        buffer: &mut I,
        timeout: &Self::Timeout,
    ) -> Result<usize, (usize, Self::Error)>
       where I: AsMut<[u8]> + ?Sized { ... }
}
Expand description

Implementors of this trait offer octet based serial data reception using a blocking API with an upper bound on blocking time, and requiring a mutable reference to self.

Required Associated Types§

Source

type Timeout

The type used to specify the timeout.

Source

type Error

The error type returned if getc fails.

Required Methods§

Source

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

Read a single octet from the port’s receiver, blocking until the octet can be read from the buffer.

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

If it times out, Ok(None) is returned. If it receives data, Ok(Some(data)) is returned. If it fails, Err(…) is returned.

Provided Methods§

Source

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

Read a specified number of octets into the given buffer, blocking until that many have been read or a timeout occurs.

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

If the result is Ok(size) but size <= buffer.len(), you had a timeout.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§