pub struct StreamMark {
pub seq: u64,
pub beat: u64,
pub age_ms: Option<u64>,
pub pk: Option<String>,
pub sig: Option<String>,
}Expand description
What a runtime knows of one stream: the contiguous high-water sequence, the highest
beat with its origin’s signature, and how long ago that beat was seen to rise (None
when never).
A mark is both halves of replication in one value. The sequence is what a peer compares to decide what to send, which is why replication is a comparison rather than a flood. The beat is how liveness crosses machines without comparing clocks: the origin signs it, a relay forwards the signature and adds how long ago it saw the beat rise, and the reader converts that to freshness on its own monotonic clock. Because only the origin can sign its beat, a relay can carry a stream’s liveness without being able to invent it.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::{EventBody, Journal, StreamMark};
let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
"repo".into(), None).unwrap();
j.append_own(EventBody::SessionClosed { session: "s1".into() }).unwrap();
j.beat_own();
let marks = j.marks();
let mark: &StreamMark = &marks[&j.own_stream()];
assert_eq!(mark.seq, 1, "every event up to here is held");
assert!(mark.beat > 0 && mark.sig.is_some(), "the beat is the origin's signed statement");Fields§
§seq: u64Every event up to and including this sequence is held.
beat: u64The highest beat heard.
age_ms: Option<u64>Milliseconds since that beat rose, on the sender’s monotonic clock. Clamped by the reader to its expiry: a relay can report a beat stale, never older than dead.
pk: Option<String>The origin’s public key, hex: the beat is its statement.
sig: Option<String>The origin’s signature over the stream and the beat, hex. A relay forwards it verbatim; only the origin can raise its own beat.
Trait Implementations§
Source§impl Clone for StreamMark
impl Clone for StreamMark
Source§fn clone(&self) -> StreamMark
fn clone(&self) -> StreamMark
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamMark
impl Debug for StreamMark
Source§impl Default for StreamMark
impl Default for StreamMark
Source§fn default() -> StreamMark
fn default() -> StreamMark
Source§impl<'de> Deserialize<'de> for StreamMark
impl<'de> Deserialize<'de> for StreamMark
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>,
impl Eq for StreamMark
Source§impl JsonSchema for StreamMark
impl JsonSchema for StreamMark
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for StreamMark
impl PartialEq for StreamMark
Source§fn eq(&self, other: &StreamMark) -> bool
fn eq(&self, other: &StreamMark) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for StreamMark
impl Serialize for StreamMark
impl StructuralPartialEq for StreamMark
Auto Trait Implementations§
impl Freeze for StreamMark
impl RefUnwindSafe for StreamMark
impl Send for StreamMark
impl Sync for StreamMark
impl Unpin for StreamMark
impl UnsafeUnpin for StreamMark
impl UnwindSafe for StreamMark
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
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
key and return true if they are equal.