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§
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
Mutably borrows from an owned value. Read more
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> 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>
Converts
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>
Converts
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