Struct cid::CidGeneric [−][src]
Representation of a CID.
The generic is about the allocated size of the multihash.
Implementations
impl<S: Size> Cid<S>
[src]
pub fn new_v0(hash: Multihash<S>) -> Result<Self>
[src]
Create a new CIDv0.
pub fn new_v1(codec: u64, hash: Multihash<S>) -> Self
[src]
Create a new CIDv1.
pub fn new(version: Version, codec: u64, hash: Multihash<S>) -> Result<Self>
[src]
Create a new CID.
pub fn version(&self) -> Version
[src]
Returns the cid version.
pub fn codec(&self) -> u64
[src]
Returns the cid codec.
pub fn hash(&self) -> &Multihash<S>
[src]
Returns the cid multihash.
pub fn read_bytes<R: Read>(r: R) -> Result<Self>
[src]
Reads the bytes from a byte stream.
pub fn write_bytes<W: Write>(&self, w: W) -> Result<()>
[src]
Writes the bytes to a byte stream.
pub fn to_bytes(&self) -> Vec<u8>
[src]
Returns the encoded bytes of the Cid
.
pub fn to_string_of_base(&self, base: Base) -> Result<String>
[src]
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<S: Clone + Size> Clone for Cid<S>
[src]
impl<S: Size> Copy for Cid<S> where
S::ArrayType: Copy,
[src]
S::ArrayType: Copy,
impl<S: Debug + Size> Debug for Cid<S>
[src]
impl<S: Size> Default for Cid<S>
[src]
impl<S: Size> Display for Cid<S>
[src]
impl<S: Eq + Size> Eq for Cid<S>
[src]
impl<S: Size> From<&'_ Cid<S>> for Cid<S> where
S::ArrayType: Copy,
[src]
S::ArrayType: Copy,
impl<'a, S: Size> From<&'a Cid<S>> for Cow<'a, Cid<S>>
[src]
impl<S: Size> From<Cid<S>> for Vec<u8>
[src]
impl<S: Size> From<Cid<S>> for String
[src]
impl<'a, S: Size> From<Cid<S>> for Cow<'a, Cid<S>>
[src]
impl<S: Size> FromStr for Cid<S>
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(cid_str: &str) -> Result<Self>
[src]
impl<S: Hash + Size> Hash for Cid<S>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<S: Ord + Size> Ord for Cid<S>
[src]
fn cmp(&self, other: &Cid<S>) -> Ordering
[src]
#[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 + Size> PartialEq<Cid<S>> for Cid<S>
[src]
impl<S: PartialOrd + Size> PartialOrd<Cid<S>> for Cid<S>
[src]
fn partial_cmp(&self, other: &Cid<S>) -> Option<Ordering>
[src]
#[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: Size> StructuralEq for Cid<S>
[src]
impl<S: Size> StructuralPartialEq for Cid<S>
[src]
impl<S: Size> TryFrom<&'_ [u8]> for Cid<S>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(bytes: &[u8]) -> Result<Self>
[src]
impl<S: Size> TryFrom<&'_ str> for Cid<S>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(cid_str: &str) -> Result<Self>
[src]
impl<S: Size> TryFrom<String> for Cid<S>
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(cid_str: String) -> Result<Self>
[src]
impl<S: Size> TryFrom<Vec<u8, Global>> for Cid<S>
[src]
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
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>,