Skip to main content

AsyncUart

Struct AsyncUart 

Source
pub struct AsyncUart { /* private fields */ }
Expand description

Async wrapper around an ove::Uart.

Same lifetime contract as the other Async* wrappers: methods take &'static self because the C-side notify callback retains a pointer to the internal AtomicWaker.

Implementations§

Source§

impl AsyncUart

Source

pub const fn new(inner: Uart) -> Self

Source

pub fn arm(&'static self) -> Result<()>

Register the C-side notify callback. Must be called exactly once after the wrapper reaches its final ’static location.

Source

pub async fn read(&'static self, buf: &mut [u8]) -> Result<usize>

Async read — awaits until at least one byte is available, then returns the number of bytes copied.

Returns Ok(0) only if buf.is_empty().

Source

pub fn inner(&self) -> &Uart

Borrow the underlying Uart for synchronous operations (write, bytes_available, flush).

Trait Implementations§

Source§

impl ErrorType for &'static AsyncUart

Source§

type Error = Error

Error type of all the IO operations on this type.
Source§

impl Read for &'static AsyncUart

Source§

async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>

Read some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

async fn read_exact( &mut self, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>

Read the exact number of bytes required to fill buf. Read more
Source§

impl Send for AsyncUart

Source§

impl Sync for AsyncUart

Auto Trait Implementations§

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.