Skip to main content

Stream

Struct Stream 

Source
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:

  1. folds a !stream marker into the interface hash (so a streaming method can never be confused with a unary -> T method of the same name/args — a producer/consumer mismatch is rejected at load), and
  2. (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 a ChunkStream host-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 via Stream::next_item to 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>

Source

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.

Source

pub fn from_iter<I>(items: I) -> Stream<T>
where I: IntoIterator<Item = T>, <I as IntoIterator>::IntoIter: Send + 'static,

Build a stream from any iterator — how a Rust WASM guest produces its items. The iterator must be Send + 'static so the host can drive the component resource across its pump thread.

Source

pub fn next_item(&mut self) -> Option<T>

Advance the underlying iterator by one item. Driven by the macro-generated component resource’s next() (WS.2). Returns None for the marker form and at end of iteration.

Trait Implementations§

Source§

impl<T> Default for Stream<T>

Source§

fn default() -> Stream<T>

Returns the “default value” for a type. Read more

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more