Skip to main content

TokioUartFrontend

Struct TokioUartFrontend 

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

Tokio host UART frontend adapter.

T can be a Tokio serial stream, TCP stream used as a UART-like byte stream, or any async byte stream implementing AsyncRead + AsyncWrite + Unpin.

Implementations§

Source§

impl<T> TokioUartFrontend<T>
where T: AsyncRead + AsyncWrite + Unpin,

Source

pub fn new(io: T) -> Self

Creates a frontend adapter using default MSRT config.

Source

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

Creates a frontend 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 async IO object.

Source

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

Returns a mutable reference to the owned async IO object.

Source

pub fn into_inner(self) -> T

Consumes the adapter and returns the async IO object.

Source

pub fn connect(&mut self) -> TokioResult<()>

Starts a fresh frontend session.

Source

pub fn disconnect(&mut self)

Drops the active frontend session.

Source

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

Queues an application message.

Source

pub async fn receive_available(&mut self) -> TokioResult<usize>

Reads currently available UART bytes and feeds them into MSRT.

Source

pub async fn poll(&mut self) -> TokioResult<UartFrontendEvent>

Polls one frontend event and writes pending UART bytes.

Source

pub async fn tick(&mut self) -> TokioResult<UartFrontendEvent>

Runs receive_available followed by poll.

Trait Implementations§

Source§

impl<T: Debug> Debug for TokioUartFrontend<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 TokioUartFrontend<T>
where T: Freeze,

§

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

§

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

§

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

§

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

§

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

§

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