pub struct CheckoutId(/* private fields */);Expand description
One checkout of a repository: the primary one, or one linked worktree of it.
crate::repository::identity’s digest of the checkout root — the value this
executable’s lease, index and server already key a checkout by. Two worktrees of one
repository share a RepositoryId and differ here, which is the distinction the
continuity resolver’s first tier is made of: a record from another worktree is never
silently offered as your context.
use majordomus_cli::session::{CheckoutId, RepositoryId};
use std::path::Path;
let a = CheckoutId::of(Path::new("/a/b"));
let b = CheckoutId::of(Path::new("/a/c"));
assert_ne!(a, b, "two checkouts");
assert_eq!(a, CheckoutId::of(Path::new("/a/b")), "the same checkout across runs");
assert!(!a.as_str().contains('/'), "a digest, never a path");
// and the two identities are not interchangeable: this does not compile.
// let _: RepositoryId = a;
let _ = RepositoryId::recorded("unused");Implementations§
Source§impl CheckoutId
impl CheckoutId
Sourcepub fn of(root: &Path) -> Self
pub fn of(root: &Path) -> Self
The checkout rooted at root. Total: a path that does not exist still has an
identity, because the question “which checkout is this record about” has to be
answerable for a record written on a disk that has since been unmounted.
use majordomus_cli::session::CheckoutId;
use std::path::Path;
let gone = CheckoutId::of(Path::new("/Volumes/unmounted/repo"));
assert_eq!(gone.as_str().len(), 32, "a path that does not exist still has one");Sourcepub fn recorded(value: impl Into<String>) -> Self
pub fn recorded(value: impl Into<String>) -> Self
A value read back from a record that carries one. Whatever the store wrote is accepted: a record written by an older version of the tool carries an older spelling, and refusing it would lose the record.
use majordomus_cli::session::CheckoutId;
use std::path::Path;
// a record's own string is taken as it stands, never made to agree with a digest
assert_ne!(CheckoutId::recorded("2b0f1c8e9a774d31"), CheckoutId::of(Path::new("/a/b")));Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
The value as text: what a shared record writes as worktree_id:. It is never
compared with a repository identity, which is a different question with a different
answer.
use majordomus_cli::session::CheckoutId;
assert_eq!(CheckoutId::recorded("2b0f1c8e").as_str(), "2b0f1c8e");Trait Implementations§
Source§impl Clone for CheckoutId
impl Clone for CheckoutId
Source§fn clone(&self) -> CheckoutId
fn clone(&self) -> CheckoutId
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 CheckoutId
impl Debug for CheckoutId
Source§impl<'de> Deserialize<'de> for CheckoutId
impl<'de> Deserialize<'de> for CheckoutId
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 CheckoutId
Source§impl Hash for CheckoutId
impl Hash for CheckoutId
Source§impl JsonSchema for CheckoutId
impl JsonSchema for CheckoutId
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 Ord for CheckoutId
impl Ord for CheckoutId
Source§fn cmp(&self, other: &CheckoutId) -> Ordering
fn cmp(&self, other: &CheckoutId) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for CheckoutId
impl PartialEq for CheckoutId
Source§fn eq(&self, other: &CheckoutId) -> bool
fn eq(&self, other: &CheckoutId) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialOrd for CheckoutId
impl PartialOrd for CheckoutId
Source§impl Serialize for CheckoutId
impl Serialize for CheckoutId
impl StructuralPartialEq for CheckoutId
Auto Trait Implementations§
impl Freeze for CheckoutId
impl RefUnwindSafe for CheckoutId
impl Send for CheckoutId
impl Sync for CheckoutId
impl Unpin for CheckoutId
impl UnsafeUnpin for CheckoutId
impl UnwindSafe for CheckoutId
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.