pub enum SessionState {
Offline,
Paused,
Blocked,
MustClear,
Waiting,
Busy,
Idle,
}Expand description
The state of a session. The server derives it from facts; no session reports it (01M3QB6CJ1XCQG5B1BVR8AF3B4, 01M41FZQVEF8S2W9RCM4V87C3D). The first state that matches wins, in this order:
offline: the session has no open watch stream. A lead is not offline while it is not gone, also with no watch (01M48VDGQ5KETKPM4G6TKTC2MB). A session in a container is not offline while the keep-alive of the riff daemon comes (01M510MG0CKDXAKF6YJ768K7E8).paused: the riff is paused, or the repository of the session is paused (01M3XAHZBGSSJB3YX23K88W01K).blocked: the session said that it cannot go on with no decision, and the block holds (01M41FZPGEK4TNPSM2051W4VMS). A lead with a block iswaitingfor its person (01M48VDS8RKJS9HG3KSEYGBFGV).must_clear: it is a worker that must clear its context before its next claim (01M3X9XAK1KPZZVM1AJR2H8DSS).waiting: each claim of the session waits for the machinery: a verify, a merge, or an item of itsNeeds:line (01M41FZP9A50CH4A2VX344DW49). Or a lead waits for its person.busy: it holds a claim. Or it is the lead, and a turn runs.idle: each other session.
stateDiagram-v2
[*] --> idle
idle --> busy: claim
busy --> waiting: a verify is asked, a merge waits, a need is open
waiting --> busy: the fact ends
busy --> blocked: blocked REASON (wakes the lead)
blocked --> busy: an answer, then a sign of work
busy --> must_clear: the last release of a worker
must_clear --> idle: a clearuse riff_core::wire::{Facts, SessionState};
let all = Facts {
live: true, paused: true, blocked: true, must_clear: true,
waiting: true, claims: true, lead: false, turn: false,
};
let of = |f: Facts| SessionState::of(&f);
assert_eq!(of(Facts { live: false, ..all }), SessionState::Offline);
assert_eq!(of(all), SessionState::Paused);
let running = Facts { paused: false, ..all };
assert_eq!(of(running), SessionState::Blocked);
let free = Facts { blocked: false, ..running };
assert_eq!(of(free), SessionState::MustClear);
let cleared = Facts { must_clear: false, ..free };
assert_eq!(of(cleared), SessionState::Waiting);
assert_eq!(of(Facts { waiting: false, ..cleared }), SessionState::Busy);
let none = Facts { waiting: false, claims: false, ..cleared };
assert_eq!(of(none), SessionState::Idle);
// A lead: busy in a turn, waiting for its person, idle else.
let lead = Facts { lead: true, ..none };
assert_eq!(of(lead), SessionState::Idle);
assert_eq!(of(Facts { turn: true, ..lead }), SessionState::Busy);
assert_eq!(of(Facts { blocked: true, turn: true, ..lead }), SessionState::Waiting);
assert_eq!(serde_json::to_string(&SessionState::MustClear).unwrap(), r#""must_clear""#);
assert_eq!(SessionState::MustClear.word(), "must clear");
assert_eq!(serde_json::to_string(&SessionState::Waiting).unwrap(), r#""waiting""#);
assert_eq!(SessionState::Blocked.word(), "blocked");Variants§
Implementations§
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionState
impl Debug for SessionState
Source§impl Default for SessionState
impl Default for SessionState
Source§fn default() -> SessionState
fn default() -> SessionState
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SessionState
impl<'de> Deserialize<'de> for SessionState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for SessionState
impl JsonSchema for SessionState
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for SessionState
impl PartialEq for SessionState
Source§impl Serialize for SessionState
impl Serialize for SessionState
impl Copy for SessionState
impl Eq for SessionState
impl StructuralPartialEq for SessionState
Auto Trait Implementations§
impl Freeze for SessionState
impl RefUnwindSafe for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl UnsafeUnpin for SessionState
impl UnwindSafe for SessionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.