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§
Required Methods§
Sourcefn getc_wait(
&mut self,
timeout: &Self::Timeout,
) -> Result<Option<u8>, Self::Error>
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§
Sourcefn gets_wait<I>(
&mut self,
buffer: &mut I,
timeout: &Self::Timeout,
) -> Result<usize, (usize, Self::Error)>
fn gets_wait<I>( &mut self, buffer: &mut I, timeout: &Self::Timeout, ) -> Result<usize, (usize, Self::Error)>
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.