pub struct Stream<T> { /* private fields */ }Expand description
Marker type a plugin interface uses to declare a server-streaming method:
ⓘ
#[fidius::plugin_interface(version = 1, buffer = PluginAllocated)]
pub trait Source: Send + Sync {
fn read(&self, config: String) -> fidius::Stream<Row>;
}#[plugin_interface] recognises a return type whose final path segment is
Stream<T> and, for that method:
- folds a
!streammarker into the interface hash (so a streaming method can never be confused with a unary-> Tmethod of the same name/args — a producer/consumer mismatch is rejected at load), and - (Phase 1+) generates a host-side client method returning the runtime
pull handle (
fidius_host::ChunkStream).
The marker carries no data — the runtime representation of a stream is the
host-side ChunkStream, not this type. It exists so the interface trait
type-checks and so the macro has an explicit, unambiguous thing to detect
(rather than guessing from impl Stream). T is the per-item type and
follows the same wire/WitType rules as a unary return.
Argument-position Stream<T> (client-streaming / bidirectional) is rejected
in v1.
§Two forms (FIDIUS-I-0026)
- Marker form (
Stream::new): no items. Used purely to declare a streaming method in an interface trait — the Python path (Phase 1) never iterates it in Rust (its generator is bridged to aChunkStreamhost-side). - Iterator-backed form (
Stream::from_iter): a Rust WASM guest (Phase 2) returns real items. The macro-generated component resource pulls them one at a time viaStream::next_itemto satisfy the WIT contract:resource <m>-stream { next: func() -> result<option<T>, plugin-error>; } <m>: func(args) -> own<<m>-stream>;some(item)= item,none= clean end,err= mid-stream error; dropping the resource runs the guest dtor = cancel (design decision D3).
Implementations§
Source§impl<T> Stream<T>
impl<T> Stream<T>
Sourcepub fn new() -> Stream<T>
pub fn new() -> Stream<T>
The marker form — declares a streaming method without producing items. The interface/Python path uses this; it is never iterated in Rust.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Stream<T>
impl<T> !Sync for Stream<T>
impl<T> !UnwindSafe for Stream<T>
impl<T> Freeze for Stream<T>
impl<T> Send for Stream<T>
impl<T> Unpin for Stream<T>
impl<T> UnsafeUnpin for Stream<T>
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