[−][src]Enum iprs::cid::Cid
Content Identifier.
Variants
Zero(Multihash)
Cid version ZERO. Actually this is legacy. In the distant future, we may remove this support after sha2 breaks.
One(Base, Multicodec, Multihash)
Cid version ONE.
Implementations
impl Cid
[src]
pub fn new_v0(data: &[u8]) -> Result<Cid>
[src]
Create a new Cid in Version-0 format from data
. Here data
shall be encoded in Multihash specification using SHA2-256
cryptographic hash algorithm.
- multibase, base58btc is implied.
- multicodec, dag-pb is implied.
- cid-version, cidv0 is implied.
- multihash is SHA2_256 computed from
data
.
Refer to CIDv0 spec for details
pub fn new_v1(base: Base, codec: Multicodec, data: &[u8]) -> Result<Cid>
[src]
Create a new Cid in Version-1 format from data
.
cidv1 ::= multibase-prefix + multicodec-cidv1 + codec + multihash
- base, describes base-encoding to be used for this Cid.
- codec, describes multicodec-content-type of the data.
- multihash, is SHA2_256 computed from
data
.
Refer to CIDv1 spec for details
pub fn into_v1(self) -> Self
[src]
Transform into v1 addressing.
pub fn from_peer_id_v0(peer_id: PeerId) -> Self
[src]
Create a Cid-v0 from peer-id.
pub fn from_peer_id_v1(base: Base, peer_id: PeerId) -> Self
[src]
Create a Cid-v1 from peer-id. codec value is implied as LIBP2P_KEY.
pub fn from_text(text: &str) -> Result<Cid>
[src]
Decode a base encoded CID, human readable text. CID format can either be in legacy (v0) format or CIDv1 format.
pub fn to_base_text(&self) -> Result<String>
[src]
Encode in base format.
- If value is a CIDv0 variant, encoded into legacy base58btc format.
- If value is a CIDv1 variant, encoded using specified base format.
pub fn decode(bytes: &[u8]) -> Result<Cid>
[src]
Decode a binary encoded CID. Refer to Self::encode method for details. Supports both legacy-format and CIDv1-format.
pub fn encode(&self) -> Result<Vec<u8>>
[src]
Encode to binary format.
If value is a CIDv0 variant:
- Encoded as binary multi-hash format. The resulting bytes start with [0x12, 0x20, ...]
If value is a CIDv1 variant:
- CID-version byte
- codec, unsigned_varint multicodec value, describing multicodec-content-type or format of the data being addressed
- multihash, is SHA2-256 of data in Multihash format.
pub fn to_version(&self) -> Version
[src]
Return CID version.
pub fn to_base(&self) -> Base
[src]
Return the base encoding used for this CID.
pub fn to_content_type(&self) -> Multicodec
[src]
Return the content type or format of the data being addressed.
pub fn to_multihash(&self) -> Multihashⓘ
[src]
Return hash digest, typically encoded with SHA2-256, in which case it must be a 32-byte vector.
pub fn to_peer_id(&self) -> Option<PeerId>
[src]
If CID is pointing to a peer-id, that is if the codec is LIBP2P_KEY, return the PeerId value.
Trait Implementations
impl Clone for Cid
[src]
impl Debug for Cid
[src]
impl Display for Cid
[src]
impl Eq for Cid
[src]
impl FromStr for Cid
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Cid>
[src]
impl PartialEq<Cid> for Cid
[src]
impl StructuralEq for Cid
[src]
impl StructuralPartialEq for Cid
[src]
Auto Trait Implementations
impl RefUnwindSafe for Cid
impl Send for Cid
impl Sync for Cid
impl Unpin for Cid
impl UnwindSafe for Cid
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,
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
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.
fn to_owned(&self) -> T
[src]
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,