Skip to main content

Stream

Struct Stream 

Source
pub struct Stream<'a> { /* private fields */ }
Expand description

An active streaming run, borrowed from a Session.

Feed PCM with Stream::feed, read the UI-stable text with Stream::text, and end input with Stream::finalize. Dropping the Stream (without finalizing) abandons it and returns the session to idle. Send but not Sync, like the session it borrows.

Implementations§

Source§

impl Stream<'_>

Source

pub fn feed(&mut self, pcm: &[f32]) -> Result<StreamUpdate>

Feed a chunk of 16 kHz mono float32 PCM and return the change metadata.

Source

pub fn finalize(&mut self) -> Result<StreamUpdate>

Signal end of input: flush buffered audio and emit the final text. The session transitions to finished.

Source

pub fn reset(&mut self)

Abandon the stream and return the session to idle (clears all snapshot state). Releases the model’s compute lease (the stream is no longer active), so other sessions of the model can proceed without waiting for this Stream to drop.

Source

pub fn text(&self) -> StreamText

The current UI-facing text snapshot (owned copies).

Source

pub fn snapshot(&self) -> Transcript

A full structured snapshot (segments/words/tokens) of the current hypothesis. For most UIs Stream::text is the better choice.

Source

pub fn state(&self) -> StreamState

The stream’s lifecycle state.

Source

pub fn revision(&self) -> i32

The monotonic snapshot revision; diff against the previous value.

Source

pub fn last_status(&self) -> Option<Error>

The stream’s recorded terminal failure, or None while it is healthy.

Set after a feed / finalize transitioned the stream to StreamState::Failed; reset by a new stream. Inspect it when state is Failed to learn why.

Source

pub fn was_aborted(&self) -> bool

Whether the stream was ended by cancellation.

Trait Implementations§

Source§

impl Debug for Stream<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Stream<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !Sync for Stream<'a>

§

impl<'a> !UnwindSafe for Stream<'a>

§

impl<'a> Freeze for Stream<'a>

§

impl<'a> RefUnwindSafe for Stream<'a>

§

impl<'a> Send for Stream<'a>

§

impl<'a> Unpin for Stream<'a>

§

impl<'a> UnsafeUnpin for Stream<'a>

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.