Skip to main content

AsyncStream

Struct AsyncStream 

Source
pub struct AsyncStream<const N: usize> { /* private fields */ }
Expand description

Async wrapper around an ove::Stream.

Owns the wrapped stream and the AtomicWaker used to bridge the C-level notify hook into the embassy executor’s wake path.

Implementations§

Source§

impl<const N: usize> AsyncStream<N>

Source

pub const fn new(inner: Stream<N>) -> Self

Wrap a stream for async use. Does not arm the notify hook yet — call Self::arm after the wrapper has reached its final ’static location (the C callback retains a pointer to the internal AtomicWaker, so the wrapper must not move after arming).

Source

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

Register the C-side notify callback. Must be called exactly once, and only after the wrapper is at its final ’static address.

Source

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

Receive up to buf.len() bytes. 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) -> &Stream<N>

Borrow the underlying Stream for synchronous operations (send, bytes_available, …). The async read is the only path that touches the AtomicWaker; non-blocking access through this borrow is independent.

Trait Implementations§

Source§

impl<const N: usize> ErrorType for &'static AsyncStream<N>

Source§

type Error = Error

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

impl<const N: usize> Read for &'static AsyncStream<N>

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<const N: usize> Send for AsyncStream<N>

Source§

impl<const N: usize> Sync for AsyncStream<N>

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for AsyncStream<N>

§

impl<const N: usize> !RefUnwindSafe for AsyncStream<N>

§

impl<const N: usize> Unpin for AsyncStream<N>

§

impl<const N: usize> UnsafeUnpin for AsyncStream<N>

§

impl<const N: usize> UnwindSafe for AsyncStream<N>

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.