pub struct SessionStarted {
pub session: SessionUri,
pub reason: StartReason,
pub worker: bool,
}Expand description
A start of a session.
use riff_core::record::{Change, Line};
use riff_core::wire::StartReason;
let line = r#"{"position":4,"written_at_ms":9,"change":{"session_started":{"session":"riff://ann@heron/acme/app?session=s1","reason":"clear","worker":true}}}"#;
let Line::Record(record) = Line::parse(line)? else { panic!("a known kind") };
let Change::SessionStarted(started) = &record.change else { panic!("a start") };
assert!(started.worker && started.reason.is_fresh());
assert_eq!(serde_json::to_string(&record).unwrap(), line);
// A reason of a later build reads as `other`. It is no fresh start.
let later = line.replace("clear", "wake");
let Line::Record(record) = Line::parse(&later)? else { panic!("a known kind") };
let Change::SessionStarted(started) = &record.change else { panic!("a start") };
assert_eq!(started.reason, StartReason::Other);
assert!(!started.reason.is_fresh());Fields§
§session: SessionUri§reason: StartReasonWhy the record is there. process and clear are fresh starts.
worker: boolTrue when the session is a worker.
Trait Implementations§
Source§impl Clone for SessionStarted
impl Clone for SessionStarted
Source§fn clone(&self) -> SessionStarted
fn clone(&self) -> SessionStarted
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 SessionStarted
impl Debug for SessionStarted
Source§impl<'de> Deserialize<'de> for SessionStarted
impl<'de> Deserialize<'de> for SessionStarted
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 SessionStarted
impl JsonSchema for SessionStarted
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 SessionStarted
impl PartialEq for SessionStarted
Source§impl Serialize for SessionStarted
impl Serialize for SessionStarted
impl Eq for SessionStarted
impl StructuralPartialEq for SessionStarted
Auto Trait Implementations§
impl Freeze for SessionStarted
impl RefUnwindSafe for SessionStarted
impl Send for SessionStarted
impl Sync for SessionStarted
impl Unpin for SessionStarted
impl UnsafeUnpin for SessionStarted
impl UnwindSafe for SessionStarted
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.