pub struct ClaimView {
pub key: String,
pub stream: StreamId,
pub runtime: String,
pub session: String,
pub scope: Vec<String>,
pub intent: Option<String>,
pub mode: ClaimMode,
pub issue: Option<String>,
pub acquired_lamport: u64,
pub acquired_seq: u64,
pub state: ClaimState,
}Expand description
One claim anywhere in the mesh: who took what, for what, and where it stands. The acquisition’s Lamport stamp and sequence are carried rather than derived on demand, because they are what exclusivity is decided by — every runtime ranks two competing claims by the same triple and so names the same winner, with no message passing and no “last packet wins”.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::{ClaimMode, EventBody, Journal, StreamLiveness};
use majordomus_cli::mesh::state::{fold, ClaimState, ClaimView};
let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
"repo".into(), None).unwrap();
j.append_own(EventBody::ClaimAcquired { claim: "c1".into(), session: "s1".into(),
scope: vec!["apps/majordomus-cli".into()], intent: Some("document the mesh".into()),
mode: ClaimMode::Exclusive, issue: Some("#184".into()) }).unwrap();
let state = fold(&j.events(), &|_| StreamLiveness::Own);
let claim: &ClaimView = &state.claims[0];
assert_eq!(claim.scope, ["apps/majordomus-cli"]);
assert_eq!(claim.state, ClaimState::Held);
assert!(claim.acquired_lamport > 0, "the order exclusivity is decided in");Fields§
§key: String<stream>/<claim>.
stream: StreamIdThe writing stream.
runtime: String<node>-<runtime>.
session: StringThe holding session’s key.
scope: Vec<String>The claimed paths.
intent: Option<String>What it is for.
mode: ClaimModeExclusive or advisory.
issue: Option<String>The issue it is for.
acquired_lamport: u64The Lamport stamp of the acquisition.
acquired_seq: u64The sequence of the acquisition within its stream: with the stamp and the stream, the total order in which exclusivity is decided.
state: ClaimStateIts standing.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ClaimView
impl<'de> Deserialize<'de> for ClaimView
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 ClaimView
Source§impl JsonSchema for ClaimView
impl JsonSchema for ClaimView
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 moreimpl StructuralPartialEq for ClaimView
Auto Trait Implementations§
impl Freeze for ClaimView
impl RefUnwindSafe for ClaimView
impl Send for ClaimView
impl Sync for ClaimView
impl Unpin for ClaimView
impl UnsafeUnpin for ClaimView
impl UnwindSafe for ClaimView
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.