embedded_runtime only.Expand description
Runtime helpers for driving embedded Hydro dataflow graphs from handwritten Rust.
The embedded backend (hydro_lang::compile::embedded, available with the build
feature) generates one function per location. Each generated function takes
[futures::Stream] inputs and FnMut output callbacks, and returns a DFIR graph that
borrows from them. Storing the graph together with its inputs and outputs in a single
owned value therefore requires a self-referential struct, which cannot be expressed in
safe Rust. This module provides the building blocks for such a holder, with all unsafe
confined to this module so that downstream integration code is safe:
InputBuffer/InputStream: an address-stable queue that backs a [futures::Stream] input parameter of a generated function.CallbackSlot: an address-stable slot holding a caller-providedFnMut(T)for the duration of a run, backing an output (or network-out) parameter.AliasedBox/OwnedErasedBox: owned heap allocations that, unlikeBox, may be moved while raw pointers into their contents exist.DfirRunnable: object-safe erasure for the unnameableDfir<impl TickClosure>.embedded_flow!: a macro assembling the above into a safe holder struct.
The same primitives support local and networked channels alike: a network-out is just a
CallbackSlot<(TaglessMemberId, Bytes)> and a network-in is just an
InputBuffer<Result<(TaglessMemberId, BytesMut), io::Error>>.
§Threading
All of these types are single-threaded: they are !Sync, and !Send wherever a raw
pointer may reference them. A holder assembled from them must live and run on one thread.
§no_std
The core primitives (InputBuffer, CallbackSlot) only use core items, have
const fn new constructors, and communicate address stability through Pin, so they
are compatible with future no_std targets using statically-allocated (fixed-size)
storage. Only the owning-allocation helpers (AliasedBox, OwnedErasedBox) and the
embedded_flow! macro require alloc.
Macros§
- embedded_
flow - Declares a holder struct that owns a generated embedded DFIR flow (see
hydro_lang::compile::embedded) together with the input buffers and output callback slots it borrows from, exposing an entirely safe API.
Structs§
- Aliased
Box - An owned heap allocation, like
Box, but withoutBox’s unique-aliasing guarantee. - Callback
Slot - An address-stable slot holding a caller-provided callback for the duration of a run, backing an output (or network-out) parameter of a generated embedded function.
- Input
Buffer - An address-stable FIFO queue that backs a [
futures::Stream] input parameter of a generated embedded function. - Input
Stream - A never-terminating [
futures::Stream] that drains anInputBuffer. - Owned
Erased Box - A type-erased owned heap allocation, dropped (running
T’s destructor) when this value is dropped.
Traits§
- Dfir
Runnable - Object-safe trait for running a DFIR flow synchronously.