Struct libipld::cid::CidGeneric [−]
Representation of a CID.
The generic is about the allocated size of the multihash.
Implementations
impl<S> Cid<S> where
S: Size,
S: Size,
pub fn new_v0(hash: Multihash<S>) -> Result<Cid<S>, Error>
Create a new CIDv0.
pub fn new_v1(codec: u64, hash: Multihash<S>) -> Cid<S>
Create a new CIDv1.
pub fn new(
version: Version,
codec: u64,
hash: Multihash<S>
) -> Result<Cid<S>, Error>
version: Version,
codec: u64,
hash: Multihash<S>
) -> Result<Cid<S>, Error>
Create a new CID.
pub fn version(&self) -> Version
Returns the cid version.
pub fn codec(&self) -> u64
Returns the cid codec.
pub fn hash(&self) -> &Multihash<S>
Returns the cid multihash.
pub fn read_bytes<R>(r: R) -> Result<Cid<S>, Error> where
R: Read,
R: Read,
Reads the bytes from a byte stream.
pub fn write_bytes<W>(&self, w: W) -> Result<(), Error> where
W: Write,
W: Write,
Writes the bytes to a byte stream.
pub fn to_bytes(&self) -> Vec<u8, Global>
Returns the encoded bytes of the Cid
.
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::{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
impl<T> AsRef<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Link<T>
[src]
pub fn as_ref(
&self
) -> &Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
[src]
&self
) -> &Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
impl<S> AsRef<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Block<S>
[src]
impl<S> Borrow<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Block<S>
[src]
impl<S> Clone for Cid<S> where
S: Clone + Size,
S: Clone + Size,
pub fn clone(&self) -> Cid<S>
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<S> Copy for Cid<S> where
S: Size,
<S as ArrayLength<u8>>::ArrayType: Copy,
S: Size,
<S as ArrayLength<u8>>::ArrayType: Copy,
impl<S> Debug for Cid<S> where
S: Size,
S: Size,
impl Decode<DagCborCodec> for Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
[src]
pub fn decode<R>(
DagCborCodec,
r: &mut R
) -> Result<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>, Error> where
R: Read + Seek,
[src]
DagCborCodec,
r: &mut R
) -> Result<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>, Error> where
R: Read + Seek,
impl<S> Default for Cid<S> where
S: Size,
S: Size,
impl<S> Display for Cid<S> where
S: Size,
S: Size,
impl Encode<DagCborCodec> for Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
[src]
impl<S> Eq for Cid<S> where
S: Eq + Size,
S: Eq + Size,
impl<'_, S> From<&'_ Cid<S>> for Cid<S> where
S: Size,
<S as ArrayLength<u8>>::ArrayType: Copy,
S: Size,
<S as ArrayLength<u8>>::ArrayType: Copy,
impl<'_> From<&'_ Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Ipld
[src]
pub fn from(
t: &Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
) -> Ipld
[src]
t: &Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
) -> Ipld
impl<'a> From<&'a Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for DagPath<'a>
[src]
impl<T> From<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Link<T>
[src]
pub fn from(
cid: Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
) -> Link<T>
[src]
cid: Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
) -> Link<T>
impl From<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>> for Ipld
[src]
pub fn from(
t: Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
) -> Ipld
[src]
t: Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>
) -> Ipld
impl<S> FromStr for Cid<S> where
S: Size,
S: Size,
type Err = Error
The associated error which can be returned from parsing.
pub fn from_str(cid_str: &str) -> Result<Cid<S>, Error>
impl<S> Hash for Cid<S> where
S: Hash + Size,
S: Hash + Size,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<S> Ord for Cid<S> where
S: Ord + Size,
S: Ord + Size,
pub fn cmp(&self, other: &Cid<S>) -> Ordering
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<S> PartialEq<Cid<S>> for Cid<S> where
S: PartialEq<S> + Size,
S: PartialEq<S> + Size,
impl<S> PartialOrd<Cid<S>> for Cid<S> where
S: PartialOrd<S> + Size,
S: PartialOrd<S> + Size,
pub fn partial_cmp(&self, other: &Cid<S>) -> Option<Ordering>
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<S> StructuralEq for Cid<S> where
S: Size,
S: Size,
impl<S> StructuralPartialEq for Cid<S> where
S: Size,
S: Size,
impl<'_, S> TryFrom<&'_ [u8]> for Cid<S> where
S: Size,
S: Size,
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(bytes: &[u8]) -> Result<Cid<S>, Error>
impl<'_, S> TryFrom<&'_ str> for Cid<S> where
S: Size,
S: Size,
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(cid_str: &str) -> Result<Cid<S>, Error>
impl<S> TryFrom<String> for Cid<S> where
S: Size,
S: Size,
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(cid_str: String) -> Result<Cid<S>, Error>
impl<S> TryFrom<Vec<u8, Global>> for Cid<S> where
S: Size,
S: Size,
Auto Trait Implementations
impl<S> RefUnwindSafe for Cid<S> where
<S as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
<S as ArrayLength<u8>>::ArrayType: RefUnwindSafe,
impl<S> Send for Cid<S>
impl<S> Sync for Cid<S>
impl<S> Unpin for Cid<S> where
<S as ArrayLength<u8>>::ArrayType: Unpin,
<S as ArrayLength<u8>>::ArrayType: Unpin,
impl<S> UnwindSafe for Cid<S> where
<S as ArrayLength<u8>>::ArrayType: UnwindSafe,
<S as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DagCbor for T where
T: Encode<DagCborCodec> + Decode<DagCborCodec>,
[src]
T: Encode<DagCborCodec> + Decode<DagCborCodec>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> References<RawCodec> for T
[src]
pub fn references<R, E>(
_c: RawCodec,
_r: &mut R,
_set: &mut E
) -> Result<(), Error> where
E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
R: Read,
[src]
_c: RawCodec,
_r: &mut R,
_set: &mut E
) -> Result<(), Error> where
E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
R: Read,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,