pub struct ID(/* private fields */);Expand description
A content-addressable identifier for an Entry or other database object.
Wraps a CID v1. Hash algorithm is self-describing via the multihash specification; BLAKE3 is the default for newly-created IDs, but any multihash algorithm present in an existing CID will be preserved through parsing and serialization.
String format uses multibase base32lower encoding, producing CID strings like
bafyr4i... (dag-cbor + blake3).
Implementations§
Source§impl ID
impl ID
Sourcepub fn from_dagcbor_bytes(data: impl AsRef<[u8]>) -> Self
pub fn from_dagcbor_bytes(data: impl AsRef<[u8]>) -> Self
Creates an ID by hashing DAG-CBOR encoded bytes with BLAKE3.
This is the primary way to create an ID from serialized entry content.
Sourcepub fn from_dagcbor_bytes_with(data: impl AsRef<[u8]>, code: Code) -> Self
pub fn from_dagcbor_bytes_with(data: impl AsRef<[u8]>, code: Code) -> Self
Creates an ID by hashing DAG-CBOR encoded bytes with the specified algorithm.
Sourcepub fn from_bytes(data: impl AsRef<[u8]>) -> Self
pub fn from_bytes(data: impl AsRef<[u8]>) -> Self
Creates an ID by hashing the given bytes with BLAKE3.
Uses the raw codec (0x55) since the bytes are not DAG-CBOR encoded content. Used for opaque blobs and non-entry identifiers.
Sourcepub fn from_bytes_with(data: impl AsRef<[u8]>, code: Code) -> Self
pub fn from_bytes_with(data: impl AsRef<[u8]>, code: Code) -> Self
Creates an ID by hashing the given bytes with the specified algorithm.
Uses the raw codec (0x55) since the bytes are not DAG-CBOR encoded content.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ID
impl<'de> Deserialize<'de> for ID
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>,
Source§impl Ord for ID
Deterministic ordering: empty IDs sort before non-empty, then by CID fields.
impl Ord for ID
Deterministic ordering: empty IDs sort before non-empty, then by CID fields.
Source§impl PartialOrd for ID
impl PartialOrd for ID
impl Eq for ID
impl StructuralPartialEq for ID
Auto Trait Implementations§
impl Freeze for ID
impl RefUnwindSafe for ID
impl Send for ID
impl Sync for ID
impl Unpin for ID
impl UnsafeUnpin for ID
impl UnwindSafe for ID
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<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> CompatExt for T
impl<T> CompatExt for T
§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.§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.