Skip to main content

UartBackend

Struct UartBackend 

Source
pub struct UartBackend<T> { /* private fields */ }
Expand description

Passive UART backend adapter.

This type does not require std or heap allocation. The caller provides time through now_ms arguments, usually from SysTick or an RTOS tick.

Implementations§

Source§

impl<T> UartBackend<T>
where T: UartIo,

Source

pub fn new(io: T) -> Self

Creates a backend adapter using default MSRT config.

Source

pub fn with_config(io: T, config: EngineConfig) -> Self

Creates a backend adapter using config.

Source

pub fn peer_state(&self) -> PeerState

Returns the endpoint peer state.

Source

pub const fn io(&self) -> &T

Returns a shared reference to the owned UART IO object.

Source

pub fn io_mut(&mut self) -> &mut T

Returns a mutable reference to the owned UART IO object.

Source

pub fn into_inner(self) -> T

Consumes the adapter and returns the UART IO object.

Source

pub fn disconnect(&mut self)

Drops the active backend session.

Source

pub fn send(&mut self, message: &[u8]) -> UartResult<bool, T::Error>

Queues an application message.

Source

pub fn receive_available(&mut self, now_ms: u64) -> UartResult<usize, T::Error>

Reads currently available UART bytes and feeds them into MSRT.

Source

pub fn poll(&mut self, now_ms: u64) -> UartResult<UartBackendEvent, T::Error>

Polls one backend event and writes pending UART bytes.

Source

pub fn tick(&mut self, now_ms: u64) -> UartResult<UartBackendEvent, T::Error>

Runs receive_available followed by poll.

Trait Implementations§

Source§

impl<T: Debug> Debug for UartBackend<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for UartBackend<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for UartBackend<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.