pub struct AttestedText {
pub value: Option<String>,
pub provenance: FieldProvenance,
pub source: String,
pub reason: Option<String>,
}Expand description
One scalar with its provenance: the unit every field of a development task is made of.
The invariant the constructors enforce, and AttestedText::is_consistent states, is
that a value is present exactly when the provenance is not FieldProvenance::Unknown.
Without it the shape can express “unknown, and here is the value”, which is the defect
this whole module exists to prevent.
Fields§
§value: Option<String>The value, absent exactly when the provenance is unknown.
provenance: FieldProvenanceWhere it came from.
source: StringThe one place a reader goes to check it: a repository-relative path with the key it was read from, a capability id, or a command. Never a machine path.
reason: Option<String>Why the provenance is what it is, when that is worth a sentence: always for
unknown and for inferred, and omitted otherwise.
Implementations§
Source§impl AttestedText
impl AttestedText
Sourcepub fn explicit(value: impl Into<String>, source: impl Into<String>) -> Self
pub fn explicit(value: impl Into<String>, source: impl Into<String>) -> Self
A value the canonical record carried under this key.
Sourcepub fn derived(value: impl Into<String>, source: impl Into<String>) -> Self
pub fn derived(value: impl Into<String>, source: impl Into<String>) -> Self
A value worked out by a rule that cannot be wrong about a readable repository.
Sourcepub fn inferred(
value: impl Into<String>,
source: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn inferred( value: impl Into<String>, source: impl Into<String>, reason: impl Into<String>, ) -> Self
A value worked out by a rule that can be wrong, with the rule stated.
Sourcepub fn unknown(source: impl Into<String>, reason: impl Into<String>) -> Self
pub fn unknown(source: impl Into<String>, reason: impl Into<String>) -> Self
No value, and why there is none.
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
The value, or the empty string. For a renderer; never for a decision.
Sourcepub fn is_consistent(&self) -> bool
pub fn is_consistent(&self) -> bool
Is the invariant held: a value present exactly when the provenance is not unknown?
use majordomus_cli::devtask::AttestedText;
assert!(AttestedText::explicit("x", "s").is_consistent());
assert!(AttestedText::unknown("s", "why").is_consistent());Trait Implementations§
Source§impl Clone for AttestedText
impl Clone for AttestedText
Source§fn clone(&self) -> AttestedText
fn clone(&self) -> AttestedText
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 AttestedText
impl Debug for AttestedText
Source§impl<'de> Deserialize<'de> for AttestedText
impl<'de> Deserialize<'de> for AttestedText
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 AttestedText
Source§impl JsonSchema for AttestedText
impl JsonSchema for AttestedText
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 AttestedText
impl PartialEq for AttestedText
Source§fn eq(&self, other: &AttestedText) -> bool
fn eq(&self, other: &AttestedText) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for AttestedText
impl Serialize for AttestedText
impl StructuralPartialEq for AttestedText
Auto Trait Implementations§
impl Freeze for AttestedText
impl RefUnwindSafe for AttestedText
impl Send for AttestedText
impl Sync for AttestedText
impl Unpin for AttestedText
impl UnsafeUnpin for AttestedText
impl UnwindSafe for AttestedText
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.