Skip to main content

Writer

Struct Writer 

Source
pub struct Writer(/* private fields */);
Expand description

A running session’s logs, the harness’s appender. Every method takes &self, so clones share them. Nothing is logged before start, nor once a write failed; a default writer has no store and logs nothing.

Implementations§

Source§

impl Writer

Source

pub fn open(store: Arc<dyn Store>) -> Result<(Self, Session), SessionError>

Opens the session in store to go on with it, and returns the session as read (retired agents and their subagents left out).

Reads like Session::read, so a broken session, or one of another format, is refused before anything is written. Then each torn tail is moved to recovered/<log>-<sha256 of the tail>.part (Repair::TornTail). Nothing is logged until start.

§Errors

As Session::read, or when setting a torn tail aside fails.

Source

pub fn start(&self)

Starts logging, once the host restored the session: what it did to restore is not logged.

Source

pub fn is_live(&self) -> bool

Whether records are logged: the writer was started, and no write failed.

Source

pub fn failure(&self) -> Option<String>

Why the logging stopped, if it did.

Source

pub fn has_written(&self) -> bool

Whether a flush wrote a record to the store, such as for a host that marks its session saved once something is.

Source

pub fn open_log(&self, log: &str, parent: Option<&str>)

Starts the log log, of an agent spawned by the agent parent, unless it has one.

Source

pub fn save( &self, log: &str, conversation: &mut Conversation, ) -> Vec<ChangeRecord>

Queues the unsaved changes of conversation for the log log and empties its outbox: the changes, each stamped with when it was made (ChangeRecord::at). When the conversation does not continue the log (Conversation::continues), as when a value made elsewhere replaced it, one Change::Reset to the whole value is queued instead. Either way the conversation then continues the log.

Source

pub fn save_value( &self, log: &str, key: &str, value: Option<Value>, starts: bool, )

Queues the saved value key of the log log, an agent’s id or SESSION, when it changed; None or a null value when it was removed. With starts, the change starts the log.

Source

pub fn fork_log( &self, from: &str, to: &str, through: Option<MessageId>, ) -> Result<SavedAgent, SessionError>

Starts the log to as a copy of the log from up to a turn boundary at or before message through (its end with None): through the last record after which no turn runs, no tool call waits for its result, the model owes no answer and nothing after through is in the conversation. What is queued is written first. The copy keeps the records’ stamps, so as_of and undo_summary read it as they read from, and has its own header and lineage. Returns the agent of the copy: its conversation continues the new log, and its saved values are those from had at the cut.

§Errors

When nothing is logged, the log to exists, from does not read or never held through, or a write fails.

Source

pub fn retire(&self, log: &str)

Queues that the agent of the log log is gone for good.

Source

pub fn flush(&self) -> Result<(), SessionError>

Writes every queued record: each started log’s records with one write, a subagent’s log before its parent’s, so a parent never refers to a subagent message that is not stored, and the SESSION log once any is started. No fsync: written is not yet proof against a power cut. A failed write stops the logging (Self::failure).

§Errors

When the logging stopped, now or before: a write failed, so what was queued is not stored and nothing more will be. A writer without a store keeps nothing and never fails.

Trait Implementations§

Source§

impl Clone for Writer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Writer

Source§

fn default() -> Self

Returns the “default value” for a type. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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 = !

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.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

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