pub enum ClaimState {
Held,
Released,
Expired(String),
Conflicted(String),
}Expand description
A claim’s standing, and — where it ended or lost — what ended it. The two variants that carry a string exist because the bare verdict is not actionable: a worker told its claim expired needs to know whether its session closed or its runtime stopped beating, and one told its claim is conflicted needs the key of the claim that beat it, which is the same key on every runtime.
use majordomus_cli::mesh::state::ClaimState;
assert!(ClaimState::Held.is_live());
assert!(ClaimState::Conflicted("s/c1".into()).is_live(), "still held, and not the winner");
assert!(!ClaimState::Released.is_live());
// the detail travels with the verdict, so a reader is never left asking who won
let value = serde_json::to_value(ClaimState::Conflicted("s/c1".into())).unwrap();
assert_eq!(value["state"], "conflicted");
assert_eq!(value["detail"], "s/c1");Variants§
Held
Live; for an exclusive claim, the winner of its scope.
Released
Released by its holder.
Expired(String)
Ended without a release: the holder’s session closed or its runtime expired.
Conflicted(String)
Live, exclusive, and beaten to its scope by the claim whose key this names.
Implementations§
Source§impl ClaimState
impl ClaimState
Sourcepub fn is_live(&self) -> bool
pub fn is_live(&self) -> bool
Whether the claim is live (held or conflicted). A conflicted claim counts as live because it has not gone away: its holder is still working, and the next claim over that scope has to meet it too. Only a release, a closed session or an expired runtime ends a claim.
use majordomus_cli::mesh::state::ClaimState;
assert!(ClaimState::Held.is_live());
assert!(ClaimState::Conflicted("s/c1".into()).is_live(), "losing is not ending");
assert!(!ClaimState::Released.is_live());
assert!(!ClaimState::Expired("its runtime stopped beating".into()).is_live());Trait Implementations§
Source§impl Clone for ClaimState
impl Clone for ClaimState
Source§fn clone(&self) -> ClaimState
fn clone(&self) -> ClaimState
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 ClaimState
impl Debug for ClaimState
Source§impl<'de> Deserialize<'de> for ClaimState
impl<'de> Deserialize<'de> for ClaimState
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 ClaimState
Source§impl JsonSchema for ClaimState
impl JsonSchema for ClaimState
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 ClaimState
impl PartialEq for ClaimState
Source§fn eq(&self, other: &ClaimState) -> bool
fn eq(&self, other: &ClaimState) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ClaimState
impl Serialize for ClaimState
impl StructuralPartialEq for ClaimState
Auto Trait Implementations§
impl Freeze for ClaimState
impl RefUnwindSafe for ClaimState
impl Send for ClaimState
impl Sync for ClaimState
impl Unpin for ClaimState
impl UnsafeUnpin for ClaimState
impl UnwindSafe for ClaimState
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.