pub struct ContextLabel { /* private fields */ }Expand description
A validated, versioned context label of the form
<namespace>/<record-type>/v<N>.
Used as the SHA3-512 domain separator for content_hash. Each consuming
application picks its own namespace and record-type segments; the grammar is
deliberately small and strict so labels are unambiguous across tenants and
versions:
- exactly three
/-separated, non-empty segments, - the third segment is
vfollowed by one or more ASCII digits (no leading zero unless the version is literally0), - all characters are printable ASCII excluding
/within a segment.
use metamorphic_log::leaf::ContextLabel;
// Any application defines its own namespace/record-type/version.
let label = ContextLabel::parse("acme/user-keys/v1").unwrap();
assert_eq!(label.as_str(), "acme/user-keys/v1");
assert_eq!(label.namespace(), "acme");
assert_eq!(label.record_type(), "user-keys");
assert_eq!(label.version(), 1);
assert!(ContextLabel::parse("missing/version").is_err());
assert!(ContextLabel::parse("a/b/v01").is_err()); // no leading zerosImplementations§
Source§impl ContextLabel
impl ContextLabel
Sourcepub fn parse(label: &str) -> Result<Self>
pub fn parse(label: &str) -> Result<Self>
Parse and validate a <namespace>/<record-type>/v<N> label.
§Errors
Returns Error::MalformedLeaf if the label does not match the grammar.
Sourcepub fn record_type(&self) -> &str
pub fn record_type(&self) -> &str
The record-type segment, e.g. "user-keys".
Trait Implementations§
Source§impl Clone for ContextLabel
impl Clone for ContextLabel
Source§fn clone(&self) -> ContextLabel
fn clone(&self) -> ContextLabel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextLabel
impl Debug for ContextLabel
impl Eq for ContextLabel
Source§impl Hash for ContextLabel
impl Hash for ContextLabel
Source§impl PartialEq for ContextLabel
impl PartialEq for ContextLabel
Source§fn eq(&self, other: &ContextLabel) -> bool
fn eq(&self, other: &ContextLabel) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ContextLabel
Auto Trait Implementations§
impl Freeze for ContextLabel
impl RefUnwindSafe for ContextLabel
impl Send for ContextLabel
impl Sync for ContextLabel
impl Unpin for ContextLabel
impl UnsafeUnpin for ContextLabel
impl UnwindSafe for ContextLabel
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
Mutably borrows from an owned value. Read more