pub enum ReviewState {
Open,
Answered,
Withdrawn,
Expired,
}Expand description
A review request’s standing: whether anybody has answered it yet. There is deliberately
no Approved or Rejected here — a request may be answered by several runtimes and the
verdicts are the answers’ own, so collapsing them into one state would throw away the
disagreement that makes a second reviewer worth asking.
use std::sync::Arc;
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::journal::{EventBody, Journal, StreamLiveness};
use majordomus_cli::mesh::state::{fold, ReviewState};
let j = Journal::open(Arc::new(NodeIdentity::ephemeral().unwrap()), "0000000000000001",
"repo".into(), None).unwrap();
j.append_own(EventBody::ReviewRequested { review: "r1".into(), session: "s1".into(),
subject: "feature/x".into(), scope: vec![], issue: None, reviewer: None, body: None }).unwrap();
let asked = fold(&j.events(), &|_| StreamLiveness::Own);
assert_eq!(asked.reviews[0].state, ReviewState::Open);
let request = asked.reviews[0].key.clone();
j.append_own(EventBody::ReviewAnswered { request, session: "s2".into(),
verdict: "approved".into(), note: None }).unwrap();
assert_eq!(fold(&j.events(), &|_| StreamLiveness::Own).reviews[0].state, ReviewState::Answered);Variants§
Open
Nobody has answered.
Answered
At least one answer.
Withdrawn
The runtime that asked ended the request: done, void or superseded. Whatever was answered before stays with it.
Expired
Nobody answered and the runtime that asked stopped beating. A reading of liveness, like a claim’s expiry, decided from the journal and the streams’ beats so that no runtime needs another’s clock — a runtime that beats again reads open again.
Implementations§
Source§impl ReviewState
impl ReviewState
Sourcepub fn is_waiting(self) -> bool
pub fn is_waiting(self) -> bool
Whether the request still waits for a verdict: open, and nothing else.
use majordomus_cli::mesh::state::ReviewState;
assert!(ReviewState::Open.is_waiting());
assert!(!ReviewState::Answered.is_waiting() && !ReviewState::Withdrawn.is_waiting());
assert!(!ReviewState::Expired.is_waiting());Trait Implementations§
Source§impl Clone for ReviewState
impl Clone for ReviewState
Source§fn clone(&self) -> ReviewState
fn clone(&self) -> ReviewState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ReviewState
Source§impl Debug for ReviewState
impl Debug for ReviewState
Source§impl<'de> Deserialize<'de> for ReviewState
impl<'de> Deserialize<'de> for ReviewState
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 ReviewState
Source§impl JsonSchema for ReviewState
impl JsonSchema for ReviewState
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 ReviewState
impl PartialEq for ReviewState
Source§fn eq(&self, other: &ReviewState) -> bool
fn eq(&self, other: &ReviewState) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ReviewState
impl Serialize for ReviewState
impl StructuralPartialEq for ReviewState
Auto Trait Implementations§
impl Freeze for ReviewState
impl RefUnwindSafe for ReviewState
impl Send for ReviewState
impl Sync for ReviewState
impl Unpin for ReviewState
impl UnsafeUnpin for ReviewState
impl UnwindSafe for ReviewState
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.