pub struct SessionView {
pub key: String,
pub stream: StreamId,
pub runtime: String,
pub node: String,
pub info: SessionInfo,
pub state: SessionState,
pub updated_lamport: u64,
}Expand description
One session anywhere in the mesh, as the fold sees it: what the session said about
itself, where it is writing from, and whether it still counts. The key is
<stream>/<session> rather than the session’s own id, because two runtimes may both
call a session s1 and the mesh has to hold them apart.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::{EventBody, Journal, SessionInfo, StreamLiveness};
use majordomus_cli::mesh::state::{fold, SessionView};
let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
"repo".into(), None).unwrap();
j.append_own(EventBody::SessionOpened { info: SessionInfo::named("s1", "claude-code") })
.unwrap();
let state = fold(&j.events(), &|_| StreamLiveness::Own);
let view: &SessionView = &state.sessions[0];
assert!(view.key.ends_with("/s1"), "qualified by the stream that wrote it: {}", view.key);
assert_eq!(view.info.client, "claude-code");
assert_eq!(view.runtime, view.stream.runtime_key());Fields§
§key: String<stream>/<session>: unique across the mesh.
stream: StreamIdThe writing stream.
runtime: String<node>-<runtime>.
node: StringThe node (machine).
info: SessionInfoWhat the session last said about itself.
state: SessionStateIts standing.
updated_lamport: u64The Lamport stamp of its latest word.
Trait Implementations§
Source§impl Clone for SessionView
impl Clone for SessionView
Source§fn clone(&self) -> SessionView
fn clone(&self) -> SessionView
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 SessionView
impl Debug for SessionView
Source§impl<'de> Deserialize<'de> for SessionView
impl<'de> Deserialize<'de> for SessionView
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
impl Eq for SessionView
Source§impl JsonSchema for SessionView
impl JsonSchema for SessionView
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 SessionView
impl PartialEq for SessionView
Source§fn eq(&self, other: &SessionView) -> bool
fn eq(&self, other: &SessionView) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for SessionView
impl Serialize for SessionView
impl StructuralPartialEq for SessionView
Auto Trait Implementations§
impl Freeze for SessionView
impl RefUnwindSafe for SessionView
impl Send for SessionView
impl Sync for SessionView
impl Unpin for SessionView
impl UnsafeUnpin for SessionView
impl UnwindSafe for SessionView
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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.