Skip to main content

Module stream

Module stream 

Source
Expand description

Async wrapper around crate::Stream using the C-level ove_stream_set_notify notify hook.

The pattern is the canonical “embassy primitive on top of an RTOS synchronous primitive”:

  1. The wrapper owns an AtomicWaker.
  2. On construction it registers a C callback against the underlying stream; the callback is AtomicWaker::wake via a void* user_data.
  3. recv_async polls the non-blocking Stream::try_recv first, and on WouldBlock registers cx.waker() into the AtomicWaker, then re-checks (avoids lost-wake races against the producer).

Lifetime constraint: the C callback retains a pointer to the AtomicWaker, so the AsyncStream’s address must be stable for its entire lifetime. The simplest pattern is a static declaration or Box::leak. Methods take &'static self to enforce this at the type level.

Structs§

AsyncStream
Async wrapper around an ove::Stream.