Skip to main content

Prelude

Struct Prelude 

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

The events that take a joining client to where a run is.

Built by RunProgress::prelude. Each method adds something to send; nothing is sent that was not asked for. See the module docs for the order and for the reasoning behind each choice.

Implementations§

Source§

impl Prelude<'_>

Source

pub fn messages(self, messages: impl Into<Vec<Message>>) -> Self

Carries the conversation as MESSAGES_SNAPSHOT, right after RUN_STARTED.

messages is everything the thread holds that is complete: the earlier turns and what this run has finished. It may hold what is open as well. The snapshot is these messages with what the prelude restates taken out, so no list makes a client hold anything twice.

A snapshot is the carrier to prefer. Every client takes it, and it is right for a client that already holds part of the conversation: it replaces the messages it carries and drops the ones it leaves out, where echo_input at most adds.

Source

pub fn echo_input(self, input: RunAgentInput) -> Self

Echoes a request on RUN_STARTED, as Runner::echo_input does on a run’s own.

The reference TypeScript client adds the echoed messages whose ids it does not hold and leaves the ones it holds as they are, so the echo carries the conversation to such a client when it holds none of it. This crate’s own client reads the echo for who owns which message and adds nothing to its conversation. messages is the carrier for the rest. What the prelude restates is taken out of input.messages as it is out of a snapshot.

The echo is the whole request: state, tools, context and forwarded properties as well as the messages.

Source

pub fn state(self, state: impl Into<Value>) -> Self

Carries the state as STATE_SNAPSHOT, before anything is re-opened.

For a run that publishes state: the STATE_DELTAs that follow patch the state the client holds, and a client that joins holds none.

Source

pub fn reopen_only(self) -> Self

Re-opens what is open without restating it, and sends no snapshot.

For a client known to hold each open entity exactly as it stands at this point of the run: see the module docs. A snapshot would replace what that client holds, so the messages given to messages are dropped; calling messages afterwards goes back to restating.

Source

pub fn into_events(self) -> Vec<Event>

The prelude, in the order to send it.

Trait Implementations§

Source§

impl<'a> Clone for Prelude<'a>

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<'a> Debug for Prelude<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Prelude<'a>

§

impl<'a> RefUnwindSafe for Prelude<'a>

§

impl<'a> Send for Prelude<'a>

§

impl<'a> Sync for Prelude<'a>

§

impl<'a> Unpin for Prelude<'a>

§

impl<'a> UnsafeUnpin for Prelude<'a>

§

impl<'a> UnwindSafe for Prelude<'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> 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.

§

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

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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