pub struct Ledger {
pub schema: String,
pub entries: Vec<Entry>,
}Expand description
Every local integration this clone recorded, newest last.
Fields§
§schema: StringThe shape version this document declares.
entries: Vec<Entry>One entry per branch; a re-integration replaces its predecessor.
Implementations§
Source§impl Ledger
impl Ledger
Sourcepub fn parse(text: &str) -> Result<Self, String>
pub fn parse(text: &str) -> Result<Self, String>
Parse a stored ledger.
An absent file is an empty ledger, because a clone that never integrated locally has recorded nothing. Malformed content refuses rather than reading as empty: an empty ledger authorizes no deletion, so a silent downgrade would be safe, but it would also hide a defect that loses real evidence.
§Errors
The detail of what could not be read: invalid JSON, or a schema this binary does not know.
Sourcepub fn record(&mut self, entry: Entry)
pub fn record(&mut self, entry: Entry)
Record one integration, replacing any earlier entry for the same branch: a branch name is reused, and the ledger answers for the branch standing now.
Sourcepub fn proof(&self, branch: &str, tip: &str) -> Option<&Entry>
pub fn proof(&self, branch: &str, tip: &str) -> Option<&Entry>
The proof this ledger offers for one branch at one observed tip.
The tip must match exactly, re-observed by the caller at the moment of action. A branch that advanced after its integration has work the trunk does not carry, so it is not a candidate at all.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ledger
impl<'de> Deserialize<'de> for Ledger
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 Ledger
impl StructuralPartialEq for Ledger
Auto Trait Implementations§
impl Freeze for Ledger
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnsafeUnpin for Ledger
impl UnwindSafe for Ledger
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
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>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.