Skip to main content

CompactBinaryUsri

Struct CompactBinaryUsri 

Source
pub struct CompactBinaryUsri {
    pub path_and_realm: u64,
    pub level_and_depth: u16,
    pub anchor_hash: u64,
}
Expand description

Compact Binary USRI — 16-byte fixed-size (OCS §13.2).

Fields§

§path_and_realm: u64

Bytes [0..7]: 56-bit path hash + 8-bit realm class

§level_and_depth: u16

Bytes [8..9]: 16-bit hierarchy level + nesting depth

§anchor_hash: u64

Bytes [10..15]: 48-bit anchor hash (stored as u64, upper 16 bits unused)

Implementations§

Source§

impl CompactBinaryUsri

Source

pub fn new( realm_class: RealmClass, path_hash: u64, level: HierarchyLevel, nesting_depth: u8, anchor_hash: u64, ) -> Self

Build a CB-USRI from components.

Source

pub fn realm_class(&self) -> u8

Extract the realm class.

Source

pub fn path_hash(&self) -> u64

Extract the 56-bit path hash.

Source

pub fn level(&self) -> u8

Extract the hierarchy level.

Source

pub fn nesting_depth(&self) -> u8

Extract the nesting depth.

Source

pub fn anchor_hash_48(&self) -> u64

Extract the 48-bit anchor hash.

Source

pub fn to_bytes(&self) -> [u8; 16]

Encode to 16 bytes (big-endian for deterministic ordering).

Source

pub fn from_bytes(bytes: &[u8; 16]) -> Self

Decode from 16 bytes.

Source

pub fn from_usri( usri_str: &str, realm_class: RealmClass, level: HierarchyLevel, nesting_depth: u8, anchor: &str, ) -> Self

Compute from a USRI string and level/depth/anchor info.

Source

pub fn to_quin_context_token(&self) -> u64

Deterministically fold the 16-byte CompactBinaryUsri (path_and_realm, level_and_depth, anchor_hash) into a zero-heap 60-bit token (MSB = 0, distinct from did:q42 topological pointers, with 56-bit scoped realm hash in bits [0..55] and SENSITIVITY_PUBLIC = 0 in bits [56..63]) for NQuin.context.

Source

pub fn to_quin_context_with_sensitivity(&self, sensitivity: u8) -> u64

Encode an NQuin.context word combining an 8-bit sensitivity class in [56..63] with the 56-bit folded CB-USRI token in [0..55].

Source

pub fn to_value(&self) -> Value

Convert to a Value::Record for inspection.

Trait Implementations§

Source§

impl Clone for CompactBinaryUsri

Source§

fn clone(&self) -> Self

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 Copy for CompactBinaryUsri

Source§

impl Debug for CompactBinaryUsri

Source§

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

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

impl Eq for CompactBinaryUsri

Source§

impl Hash for CompactBinaryUsri

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CompactBinaryUsri

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CompactBinaryUsri

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

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

§

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

Checks if this value is equivalent to the given key. Read more
§

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.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,