pub struct ClaimOverlap {
pub first: String,
pub second: String,
pub paths: Vec<(String, String)>,
}Expand description
Two live claims of different sessions whose scopes meet, at least one advisory: reported, never refused.
An overlap is information, not a verdict — it is how two workers find out they are in the same place without either being stopped. The meeting paths are listed pairwise rather than summarized, because the useful question is which path of mine meets which path of theirs.
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, ClaimOverlap};
let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
"repo".into(), None).unwrap();
for (claim, session, mode) in [
("c1", "s1", ClaimMode::Exclusive),
("c2", "s2", ClaimMode::Advisory),
] {
j.append_own(EventBody::ClaimAcquired { claim: claim.into(), session: session.into(),
scope: vec!["apps".into()], intent: None, mode, issue: None }).unwrap();
}
let state = fold(&j.events(), &|_| StreamLiveness::Own);
let overlap: &ClaimOverlap = &state.overlaps[0];
assert_ne!(overlap.first, overlap.second, "two claims, two sessions");
assert_eq!(overlap.paths, [("apps".to_string(), "apps".to_string())]);Fields§
§first: StringThe earlier claim’s key.
second: StringThe later claim’s key.
paths: Vec<(String, String)>The paths that meet, as first ↔ second pairs.
Trait Implementations§
Source§impl Clone for ClaimOverlap
impl Clone for ClaimOverlap
Source§fn clone(&self) -> ClaimOverlap
fn clone(&self) -> ClaimOverlap
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 ClaimOverlap
impl Debug for ClaimOverlap
Source§impl<'de> Deserialize<'de> for ClaimOverlap
impl<'de> Deserialize<'de> for ClaimOverlap
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 ClaimOverlap
Source§impl JsonSchema for ClaimOverlap
impl JsonSchema for ClaimOverlap
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 ClaimOverlap
impl PartialEq for ClaimOverlap
Source§fn eq(&self, other: &ClaimOverlap) -> bool
fn eq(&self, other: &ClaimOverlap) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for ClaimOverlap
impl Serialize for ClaimOverlap
impl StructuralPartialEq for ClaimOverlap
Auto Trait Implementations§
impl Freeze for ClaimOverlap
impl RefUnwindSafe for ClaimOverlap
impl Send for ClaimOverlap
impl Sync for ClaimOverlap
impl Unpin for ClaimOverlap
impl UnsafeUnpin for ClaimOverlap
impl UnwindSafe for ClaimOverlap
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.