Skip to main content

SessionFold

Struct SessionFold 

Source
pub struct SessionFold { /* private fields */ }
Expand description

A fold must be bound to one server session at construction.

ⓘ
use muse_code_sdk::fold::SessionFold;

let unbound = SessionFold::default();

Implementations§

Source§

impl SessionFold

Source

pub fn new(session_id: impl Into<String>) -> Self

An empty fold bound to session_id: events for any other session are ignored.

Source

pub const fn items(&self) -> &Items

The items the fold holds.

Source

pub const fn session_state(&self) -> &SessionState

The latest params of each session-state notification the fold applied.

Source

pub fn active_turn_id(&self) -> Option<&str>

The turn whose turn/started the fold applied last, until that turn completes, is retracted or is unqueued.

Source

pub fn turn(&self, id: &str) -> Option<&Turn>

The record of turn id, or None when no turn event the fold applied named it.

Source

pub const fn pending_gap(&self) -> Option<&DeliveryGap>

The delivery gap the fold has pending, or None. A stopped fold keeps its last gap, which nothing fills.

Source

pub const fn is_current(&self) -> bool

False while a delivery gap is pending, and for good once the owning Session lost an event or its session id was opened again on the same client.

Source

pub fn gap_filled(&mut self, next: &str) -> bool

Clears the pending gap when next is its next cursor and returns true; any other cursor leaves the gap in place and returns false.

Source

pub fn pending_approval(&self, id: &str) -> Option<&Value>

The latest params seen for a pending approval: its approval/updated refresh if any, else its request. pending_approvals keeps both.

Source

pub fn resolved_approval(&self, id: &str) -> Option<&Value>

The first approval/resolved params of approval id; a later terminal never replaces it.

Source

pub fn pending_approvals(&self) -> Vec<&PendingApproval>

Approvals awaiting a durable terminal, in the order they were first requested, each with its latest request and latest update.

Source

pub fn resolved_approvals(&self) -> Vec<&Value>

The first durable terminal per approval, in the order those first terminals arrived.

Source

pub fn pending_user_input(&self, id: &str) -> Option<&Value>

The latest userInput/requested params of question id while it awaits its first settlement.

Source

pub fn settled_user_input(&self, id: &str) -> Option<&Value>

The first userInput/settled params of question id; a later settlement never replaces it.

Source

pub fn pending_user_inputs(&self) -> Vec<&Value>

Questions awaiting a durable settlement, in the order they were first requested.

Source

pub fn settled_user_inputs(&self) -> Vec<&Value>

The first durable settlement per question, in the order those first settlements arrived.

Source

pub fn apply(&mut self, event: &Notification) -> FoldOutcome

Folds one event and reports what it changed. Events for another session and malformed params change nothing. After the owning Session stops the fold it applies nothing, or only question events after a re-open.

Trait Implementations§

Source§

impl Debug for SessionFold

Source§

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