Skip to main content

Presented

Enum Presented 

Source
pub enum Presented {
    WorkingTree,
#[non_exhaustive]
Commit { commit: String, tree: TreeState, }, }
Expand description

The revision a verdict is about.

Every verdict is a verdict at something, and saying which is half of the answer. The working tree is what a person at a terminal is looking at; the checked-out commit judged as committed is the reading a site built from that commit needs.

use majordomus_cli::evidence::freshness::Presented;

// the default of every existing reader: the checkout, with whatever it carries
let here = Presented::WorkingTree;
assert_eq!(here.commit(), None);

Variants§

§

WorkingTree

The reader’s checkout: HEAD plus every tracked, staged and untracked change in it.

§

#[non_exhaustive]
Commit

The checked-out commit, judged as committed: its own ledger, its own tree. Only presented_commit builds one, because only it checks that the commit is the one checked out and measures the tree.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§commit: String

The full commit id.

§tree: TreeState

Whether the checkout was that commit, ignoring the evidence ledger’s working copy, weakened by anything the caller knew.

Implementations§

Source§

impl Presented

Source

pub fn commit(&self) -> Option<&str>

The presented commit, when a commit rather than the working tree is presented.

use majordomus_cli::evidence::freshness::{presented_commit, Presented};
use std::process::Command;

let dir = tempfile::tempdir().unwrap();
let git = |args: &[&str]| {
    let out = Command::new("git").arg("-C").arg(dir.path()).args(args).output().unwrap();
    String::from_utf8_lossy(&out.stdout).trim().to_string()
};
git(&["init", "-q"]);
git(&["config", "user.email", "t@example.com"]);
git(&["config", "user.name", "t"]);
git(&["commit", "-q", "--allow-empty", "-m", "one"]);

let p = presented_commit(dir.path(), "HEAD", None).unwrap();
assert_eq!(p.commit(), Some(git(&["rev-parse", "HEAD"]).as_str()));
assert_eq!(Presented::WorkingTree.commit(), None);
Source

pub fn tree(&self) -> TreeState

The presented tree as the truth table reads it: TreeState::Clean for the working tree, whose changes are already in the diff, and the measured tree for a commit.

use majordomus_cli::evidence::freshness::{Presented, TreeState};
assert_eq!(Presented::WorkingTree.tree(), TreeState::Clean);

Trait Implementations§

Source§

impl Clone for Presented

Source§

fn clone(&self) -> Presented

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Presented

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Presented

Source§

impl PartialEq for Presented

Source§

fn eq(&self, other: &Presented) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Presented

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more