pub struct BranchId(/* private fields */);Expand description
A validated lineage name.
§This is not ModelName’s reason, and the rule
is deliberately different
ModelName exists because a model name is spliced into a table identifier
and SQLite cannot bind an identifier as a parameter, so the validation is
what makes the splice safe. None of that applies here. A branch_id
reaches SQL as a bound value at every one of its call sites; there is no
splice to protect. Copying ModelName’s [a-z][a-z0-9_]* rule would be
borrowing a justification that does not hold, and it would reject the two
name shapes the use case in §15.5 actually produces — a hyphenated UUID and
a path-like turn id.
What this type is for is narrower and has nothing to do with SQL:
branch_idis a primary key that four ledger tables hold a foreign key into, andbranchesis append-only under two unconditional triggers (CREATE_BRANCHES_GUARD_UPDATE). A name is therefore written once and can never be corrected — not by the crate, not by raw SQL. Validation has one chance, and this is it.- A name that differs from the caller’s intent by a trailing space is not a
typo, it is a second lineage that reads as the first. Every subsequent
on_branch("release ")resolves to a different ancestry thanon_branch("release"), both succeed, and neither reports anything. That is the failure shape this wave keeps finding, and it is cheapest to refuse at D-034’s boundary.
So the rule is: non-empty, at most MAX_BRANCH_ID bytes, no ASCII control
characters, and no leading or trailing whitespace. Refused rather than
trimmed, on §4.1’s principle — a silent repair here becomes two lineages
sharing one intent later.
§main is constructible and not forkable
Database::branches returns the trunk and
every read may name it, so BranchId::new("main") must succeed. What is
refused is creating it a second time, and that refusal belongs to
Database::fork rather than to this type: the
trunk is a lineage like any other to a reader, and only a writer has cause
to care that it already exists.
Implementations§
Trait Implementations§
impl Eq for BranchId
Source§impl From<BranchId> for String
So a BranchId can be handed straight to the 0.14.4 read surface.
impl From<BranchId> for String
So a BranchId can be handed straight to the 0.14.4 read surface.
TraversalBuilder::on_branch
and query_as_of_edges_on take
impl Into<String>, and they shipped two releases before this type existed.
This impl is what makes on_branch(id) compile rather than
on_branch(id.as_str()) — additive, and cheaper than widening four
signatures that are already public.
Source§impl Ord for BranchId
impl Ord for BranchId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for BranchId
impl PartialOrd for BranchId
impl StructuralPartialEq for BranchId
Auto Trait Implementations§
impl Freeze for BranchId
impl RefUnwindSafe for BranchId
impl Send for BranchId
impl Sync for BranchId
impl Unpin for BranchId
impl UnsafeUnpin for BranchId
impl UnwindSafe for BranchId
Blanket Implementations§
Source§impl<T> AsUncased for T
impl<T> AsUncased for T
Source§fn as_uncased(&self) -> &UncasedStr
fn as_uncased(&self) -> &UncasedStr
self to an UncasedStr.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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request