pub struct VoidCid(/* private fields */);Expand description
A content identifier for void objects.
Wraps cid::Cid with void-specific constructors, validation, and a
Display implementation so CIDs can be used directly in format strings
without calling a separate to_string() helper.
All void CIDs are CIDv1 with raw codec (0x55) and SHA-256 multihash.
Implementations§
Source§impl VoidCid
impl VoidCid
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Parses a CID from raw bytes.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validates that this CID uses void’s canonical format (CIDv1/raw/SHA-256).
Sourcepub fn dht_key(&self) -> &Multihash<64>
pub fn dht_key(&self) -> &Multihash<64>
Returns the DHT key for this CID.
Per IPFS convention, DHT provider records are keyed by the multihash portion of the CID, not the full CID. This ensures the same content stored with different CID versions (v0 vs v1) or codecs (raw vs dag-pb) maps to the same DHT key.
Methods from Deref<Target = Cid>§
Sourcepub fn write_bytes<W>(&self, w: W) -> Result<usize, Error>where
W: Write,
pub fn write_bytes<W>(&self, w: W) -> Result<usize, Error>where
W: Write,
Writes the bytes to a byte stream, returns the number of bytes written.
Sourcepub fn encoded_len(&self) -> usize
pub fn encoded_len(&self) -> usize
Returns the length in bytes needed to encode this cid into bytes.
Sourcepub fn to_string_of_base(&self, base: Base) -> Result<String, Error>
pub fn to_string_of_base(&self, base: Base) -> Result<String, Error>
Convert CID into a multibase encoded string
§Example
use cid::Cid;
use multibase::Base;
use multihash_codetable::{Code, MultihashDigest};
const RAW: u64 = 0x55;
let cid = Cid::new_v1(RAW, Code::Sha2_256.digest(b"foo"));
let encoded = cid.to_string_of_base(Base::Base64).unwrap();
assert_eq!(encoded, "mAVUSICwmtGto/8aP+ZtFPB0wQTQTQi1wZIO/oPmKXohiZueu");Trait Implementations§
Source§impl Ord for VoidCid
impl Ord for VoidCid
Source§impl PartialOrd for VoidCid
impl PartialOrd for VoidCid
impl Copy for VoidCid
impl Eq for VoidCid
impl StructuralPartialEq for VoidCid
Auto Trait Implementations§
impl Freeze for VoidCid
impl RefUnwindSafe for VoidCid
impl Send for VoidCid
impl Sync for VoidCid
impl Unpin for VoidCid
impl UnsafeUnpin for VoidCid
impl UnwindSafe for VoidCid
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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> 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