Skip to main content

StreamWriter

Struct StreamWriter 

pub struct StreamWriter { /* private fields */ }
Expand description

A writer of one of the run’s streams (Ctx::stream). Opened in workflow code, it writes the run’s stream, which close() or the run’s end completes; opened inside a step’s function, the step’s stream, which the step’s final result completes.

Implementations§

§

impl StreamWriter

pub fn name(&self) -> &str

pub fn append<T: Serialize + ?Sized>(&self, value: &T) -> Result<()>

Appends value as JSON. Never waits for the disk. Inside a step it records the running attempt; in workflow code a replay appends nothing.

pub fn append_bytes(&self, bytes: &[u8]) -> Result<()>

Appends raw bytes; readers get them back as bytes.

pub fn close(&self) -> Result<()>

Completes the stream: readers end once they have every chunk.

pub fn recorded_len(&self) -> u64

Inside a step: how many chunks the step’s earlier attempts recorded (after a crash, the durable ones). 0 on a first attempt and in workflow code.

pub fn recorded<T: DeserializeOwned>(&self) -> Result<Vec<T>>

The chunks the step’s earlier attempts recorded, decoded from JSON: a step that runs again continues after them (for a model, by passing them back as the start of its answer), so readers see no chunk twice.

pub fn recorded_raw(&self) -> Result<Vec<Payload>>

Self::recorded as payloads: JSON, or bytes after a zero byte.

pub fn is_closed(&self) -> bool

The stream was complete when it was opened: the step completed it in an earlier attempt (its appends are dropped), or it was closed.

Trait Implementations§

§

impl Clone for StreamWriter

§

fn clone(&self) -> StreamWriter

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for StreamWriter

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.