Struct LlmStream

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.

1pub struct LlmStream { /* private fields */ }

Host- or plugin-owned stream returned across the native LLM stream ABI.

Implementations

impl LlmStream

impl LlmStream

from_raw

pub unsafe fn from_raw(
    host: &NemoRelayNativeHostApiV1,
    raw: NemoRelayNativeLlmStreamV1,
) -> Result<Self>

Creates a typed stream wrapper from a raw stream table.

Safety

raw must contain callbacks and user_data produced by the same host and must not be used again after it is moved into this wrapper.

next_chunk

pub fn next_chunk(&mut self) -> Result<Option<Json>>

Polls the next stream chunk.

cancel

pub fn cancel(&mut self) -> Result<()>

Cancels the stream if it has not reached end-of-stream.

Trait Implementations

impl Drop for LlmStream

impl Drop for LlmStream

drop

fn drop(&mut self)

impl Iterator for LlmStream

impl Iterator for LlmStream

Item

type Item = Result<Value, String>

next

fn next(&mut self) -> Option<Self::Item>

next_chunk

fn next_chunk<const N: usize>(
    &mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
    Self: Sized,

size_hint

fn size_hint(&self) -> (usize, Option<usize>)

count

fn count(self) -> usizewhere
    Self: Sized,

last

fn last(self) -> Option<Self::Item>where
    Self: Sized,

advance_by

fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>

nth

fn nth(&mut self, n: usize) -> Option<Self::Item>

step_by

fn step_by(self, step: usize) -> StepBy<Self>where
    Self: Sized,

chain

fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>where
    Self: Sized,
    U: IntoIterator<Item = Self::Item>,

zip

fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
    Self: Sized,
    U: IntoIterator,

intersperse

fn intersperse(self, separator: Self::Item) -> Intersperse<Self>where
    Self: Sized,
    Self::Item: Clone,

intersperse_with

fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>where
    Self: Sized,
    G: FnMut() -> Self::Item,

map

fn map<B, F>(self, f: F) -> Map<Self, F>where
    Self: Sized,
    F: FnMut(Self::Item) -> B,

for_each

fn for_each<F>(self, f: F)where
    Self: Sized,
    F: FnMut(Self::Item),

filter

fn filter<P>(self, predicate: P) -> Filter<Self, P>where
    Self: Sized,
    P: FnMut(&Self::Item) -> bool,

filter_map

fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>where
    Self: Sized,
    F: FnMut(Self::Item) -> Option<B>,

enumerate

fn enumerate(self) -> Enumerate<Self>where
    Self: Sized,

peekable

fn peekable(self) -> Peekable<Self>where
    Self: Sized,

skip_while

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>where
    Self: Sized,
    P: FnMut(&Self::Item) -> bool,

take_while

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>where
    Self: Sized,
    P: FnMut(&Self::Item) -> bool,

map_while

fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>where
    Self: Sized,
    P: FnMut(Self::Item) -> Option<B>,

skip

fn skip(self, n: usize) -> Skip<Self>where
    Self: Sized,

take

fn take(self, n: usize) -> Take<Self>where
    Self: Sized,

scan

fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>where
    Self: Sized,
    F: FnMut(&mut St, Self::Item) -> Option<B>,

flat_map

fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>where
    Self: Sized,
    U: IntoIterator,
    F: FnMut(Self::Item) -> U,

flatten

fn flatten(self) -> Flatten<Self>where
    Self: Sized,
    Self::Item: IntoIterator,

map_windows

fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>where
    Self: Sized,
    F: FnMut(&[Self::Item; N]) -> R,

fuse

fn fuse(self) -> Fuse<Self>where
    Self: Sized,

inspect

fn inspect<F>(self, f: F) -> Inspect<Self, F>where
    Self: Sized,
    F: FnMut(&Self::Item),

by_ref

fn by_ref(&mut self) -> &mut Selfwhere
    Self: Sized,

collect

fn collect<B>(self) -> Bwhere
    B: FromIterator<Self::Item>,
    Self: Sized,

try_collect

fn try_collect<B>(
    &mut self,
) -> <<Self::Item as Try>::Residual as Residual<B>>::TryTypewhere
    Self: Sized,
    Self::Item: Try,
    <Self::Item as Try>::Residual: Residual<B>,
    B: FromIterator<<Self::Item as Try>::Output>,

collect_into

fn collect_into<E>(self, collection: &mut E) -> &mut Ewhere
    E: Extend<Self::Item>,
    Self: Sized,

partition

fn partition<B, F>(self, f: F) -> (B, B)where
    Self: Sized,
    B: Default + Extend<Self::Item>,
    F: FnMut(&Self::Item) -> bool,

is_partitioned

fn is_partitioned<P>(self, predicate: P) -> boolwhere
    Self: Sized,
    P: FnMut(Self::Item) -> bool,

try_fold

fn try_fold<B, F, R>(&mut self, init: B, f: F) -> Rwhere
    Self: Sized,
    F: FnMut(B, Self::Item) -> R,
    R: Try<Output = B>,

try_for_each

fn try_for_each<F, R>(&mut self, f: F) -> Rwhere
    Self: Sized,
    F: FnMut(Self::Item) -> R,
    R: Try<Output = ()>,

fold

fn fold<B, F>(self, init: B, f: F) -> Bwhere
    Self: Sized,
    F: FnMut(B, Self::Item) -> B,

reduce

fn reduce<F>(self, f: F) -> Option<Self::Item>where
    Self: Sized,
    F: FnMut(Self::Item, Self::Item) -> Self::Item,

try_reduce

fn try_reduce<R>(
    &mut self,
    f: impl FnMut(Self::Item, Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryTypewhere
    Self: Sized,
    R: Try<Output = Self::Item>,
    <R as Try>::Residual: Residual<Option<Self::Item>>,

all

fn all<F>(&mut self, f: F) -> boolwhere
    Self: Sized,
    F: FnMut(Self::Item) -> bool,

any

fn any<F>(&mut self, f: F) -> boolwhere
    Self: Sized,
    F: FnMut(Self::Item) -> bool,

find

fn find<P>(&mut self, predicate: P) -> Option<Self::Item>where
    Self: Sized,
    P: FnMut(&Self::Item) -> bool,

find_map

fn find_map<B, F>(&mut self, f: F) -> Option<B>where
    Self: Sized,
    F: FnMut(Self::Item) -> Option<B>,

try_find

fn try_find<R>(
    &mut self,
    f: impl FnMut(&Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryTypewhere
    Self: Sized,
    R: Try<Output = bool>,
    <R as Try>::Residual: Residual<Option<Self::Item>>,

position

fn position<P>(&mut self, predicate: P) -> Option<usize>where
    Self: Sized,
    P: FnMut(Self::Item) -> bool,

max

fn max(self) -> Option<Self::Item>where
    Self: Sized,
    Self::Item: Ord,

min

fn min(self) -> Option<Self::Item>where
    Self: Sized,
    Self::Item: Ord,

max_by_key

fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>where
    B: Ord,
    Self: Sized,
    F: FnMut(&Self::Item) -> B,

max_by

fn max_by<F>(self, compare: F) -> Option<Self::Item>where
    Self: Sized,
    F: FnMut(&Self::Item, &Self::Item) -> Ordering,

min_by_key

fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>where
    B: Ord,
    Self: Sized,
    F: FnMut(&Self::Item) -> B,

min_by

fn min_by<F>(self, compare: F) -> Option<Self::Item>where
    Self: Sized,
    F: FnMut(&Self::Item, &Self::Item) -> Ordering,

unzip

fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)where
    FromA: Default + Extend<A>,
    FromB: Default + Extend<B>,
    Self: Sized + Iterator<Item = (A, B)>,

copied

fn copied<'a, T>(self) -> Copied<Self>where
    T: Copy + 'a,
    Self: Sized + Iterator<Item = &'a T>,

cloned

fn cloned<'a, T>(self) -> Cloned<Self>where
    T: Clone + 'a,
    Self: Sized + Iterator<Item = &'a T>,

array_chunks

fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
    Self: Sized,

sum

fn sum<S>(self) -> Swhere
    Self: Sized,
    S: Sum<Self::Item>,

product

fn product<P>(self) -> Pwhere
    Self: Sized,
    P: Product<Self::Item>,

cmp

fn cmp<I>(self, other: I) -> Orderingwhere
    I: IntoIterator<Item = Self::Item>,
    Self::Item: Ord,
    Self: Sized,

cmp_by

fn cmp_by<I, F>(self, other: I, cmp: F) -> Orderingwhere
    Self: Sized,
    I: IntoIterator,
    F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,

partial_cmp

fn partial_cmp<I>(self, other: I) -> Option<Ordering>where
    I: IntoIterator,
    Self::Item: PartialOrd<<I as IntoIterator>::Item>,
    Self: Sized,

partial_cmp_by

fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
    Self: Sized,
    I: IntoIterator,
    F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,

eq

fn eq<I>(self, other: I) -> boolwhere
    I: IntoIterator,
    Self::Item: PartialEq<<I as IntoIterator>::Item>,
    Self: Sized,

eq_by

fn eq_by<I, F>(self, other: I, eq: F) -> boolwhere
    Self: Sized,
    I: IntoIterator,
    F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,

ne

fn ne<I>(self, other: I) -> boolwhere
    I: IntoIterator,
    Self::Item: PartialEq<<I as IntoIterator>::Item>,
    Self: Sized,

lt

fn lt<I>(self, other: I) -> boolwhere
    I: IntoIterator,
    Self::Item: PartialOrd<<I as IntoIterator>::Item>,
    Self: Sized,

le

fn le<I>(self, other: I) -> boolwhere
    I: IntoIterator,
    Self::Item: PartialOrd<<I as IntoIterator>::Item>,
    Self: Sized,

gt

fn gt<I>(self, other: I) -> boolwhere
    I: IntoIterator,
    Self::Item: PartialOrd<<I as IntoIterator>::Item>,
    Self: Sized,

ge

fn ge<I>(self, other: I) -> boolwhere
    I: IntoIterator,
    Self::Item: PartialOrd<<I as IntoIterator>::Item>,
    Self: Sized,

is_sorted

fn is_sorted(self) -> boolwhere
    Self: Sized,
    Self::Item: PartialOrd,

is_sorted_by

fn is_sorted_by<F>(self, compare: F) -> boolwhere
    Self: Sized,
    F: FnMut(&Self::Item, &Self::Item) -> bool,

is_sorted_by_key

fn is_sorted_by_key<F, K>(self, f: F) -> boolwhere
    Self: Sized,
    F: FnMut(Self::Item) -> K,
    K: PartialOrd,

impl Send for LlmStream

impl Send for LlmStream