pub enum TreeState {
Clean,
Dirty,
Unknown,
}Expand description
Whether a tree was the commit it sits on: the three words the ledger and git already use, typed.
unknown is not a softer clean. It is what is recorded when git could not be asked,
and not knowing is not proof, so every rule here treats it as not clean.
use majordomus_cli::evidence::freshness::TreeState;
assert_eq!(TreeState::parse("clean"), TreeState::Clean);
assert_eq!(TreeState::parse("dirty"), TreeState::Dirty);
// a word nobody wrote down is not a clean tree
assert_eq!(TreeState::parse("spotless"), TreeState::Unknown);
assert_eq!(TreeState::Dirty.as_str(), "dirty");
assert_eq!(serde_json::to_value(TreeState::Unknown).unwrap(), "unknown");Variants§
Clean
The tree was the commit: nothing but the evidence ledger differed from it.
Dirty
Something other than the evidence ledger differed from the commit.
Unknown
Git could not be asked, or the word recorded is none of the three.
Implementations§
Source§impl TreeState
impl TreeState
Sourcepub fn parse(word: &str) -> TreeState
pub fn parse(word: &str) -> TreeState
Read the word a recorder or git wrote: clean and dirty are themselves, and
anything else is TreeState::Unknown, never a guess at one of the other two.
use majordomus_cli::evidence::freshness::TreeState;
assert_eq!(TreeState::parse("clean"), TreeState::Clean);
assert_eq!(TreeState::parse("Clean"), TreeState::Unknown, "the words are exact");
assert_eq!(TreeState::parse(""), TreeState::Unknown);Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
The word itself, as the ledger and the report spell it.
use majordomus_cli::evidence::freshness::TreeState;
for t in [TreeState::Clean, TreeState::Dirty, TreeState::Unknown] {
assert_eq!(TreeState::parse(t.as_str()), t, "the word reads back as itself");
}Sourcepub fn weaker(self, other: TreeState) -> TreeState
pub fn weaker(self, other: TreeState) -> TreeState
The weaker of two statements about one tree: clean only when both say clean, dirty when either says dirty, and unknown otherwise.
This is how a caller’s own knowledge meets a measurement. A site build that knows its tree was dirty can weaken a clean measurement; nothing a caller says can make a measured dirty tree clean.
use majordomus_cli::evidence::freshness::TreeState::{Clean, Dirty, Unknown};
assert_eq!(Clean.weaker(Clean), Clean);
assert_eq!(Clean.weaker(Dirty), Dirty);
assert_eq!(Dirty.weaker(Clean), Dirty, "a given clean never overrides a dirty tree");
assert_eq!(Unknown.weaker(Dirty), Dirty);
assert_eq!(Clean.weaker(Unknown), Unknown);Trait Implementations§
impl Copy for TreeState
Source§impl<'de> Deserialize<'de> for TreeState
impl<'de> Deserialize<'de> for TreeState
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 TreeState
Source§impl JsonSchema for TreeState
impl JsonSchema for TreeState
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 moreimpl StructuralPartialEq for TreeState
Auto Trait Implementations§
impl Freeze for TreeState
impl RefUnwindSafe for TreeState
impl Send for TreeState
impl Sync for TreeState
impl Unpin for TreeState
impl UnsafeUnpin for TreeState
impl UnwindSafe for TreeState
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.