pub struct EmbeddedLeg<R, W, const N: usize> { /* private fields */ }Available on crate feature
embedded only.Expand description
Length-prefix transport over embedded-io-async byte streams.
See the module docs for the SessionTransport hook-up story.
Implementations§
Source§impl<R, W, const N: usize> EmbeddedLeg<R, W, N>
impl<R, W, const N: usize> EmbeddedLeg<R, W, N>
Sourcepub fn new(reader: R, writer: W) -> Self
pub fn new(reader: R, writer: W) -> Self
Wrap a pre-split (reader, writer) pair. Most embassy UART/USB HALs
offer a .split() that produces compatible halves; a non-splittable
shared bus needs a caller-side wrapper.
Sourcepub fn into_inner(self) -> (R, W)
pub fn into_inner(self) -> (R, W)
Recover the inner (reader, writer); consumes the leg.
Source§impl<R, W, const N: usize> EmbeddedLeg<R, W, N>
impl<R, W, const N: usize> EmbeddedLeg<R, W, N>
Sourcepub async fn send_frame(&self, data: &[u8]) -> Result<(), CoreError>
pub async fn send_frame(&self, data: &[u8]) -> Result<(), CoreError>
Send one framed message: 4-byte big-endian length prefix + payload.
Errors if data.len() exceeds the leg’s buffer N or u32::MAX, or
on any transport error from W.
Sourcepub async fn recv_frame(&self) -> Result<Bytes, CoreError>
pub async fn recv_frame(&self) -> Result<Bytes, CoreError>
Receive one framed message. Returns the payload as a fresh Bytes.
Returns CoreError::ConnectionClosed on EOF; CoreError::NetworkError
on framing errors or transport errors.
Auto Trait Implementations§
impl<R, W, const N: usize> !Freeze for EmbeddedLeg<R, W, N>
impl<R, W, const N: usize> !RefUnwindSafe for EmbeddedLeg<R, W, N>
impl<R, W, const N: usize> Send for EmbeddedLeg<R, W, N>
impl<R, W, const N: usize> Sync for EmbeddedLeg<R, W, N>
impl<R, W, const N: usize> Unpin for EmbeddedLeg<R, W, N>
impl<R, W, const N: usize> UnsafeUnpin for EmbeddedLeg<R, W, N>where
W: UnsafeUnpin,
R: UnsafeUnpin,
impl<R, W, const N: usize> UnwindSafe for EmbeddedLeg<R, W, N>where
W: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more