pub trait CidExt {
// Required methods
fn to_string_with_base(&self, base: MultibaseEncoding) -> String;
fn to_v1(&self) -> Result<Cid>;
fn to_v0(&self) -> Result<Cid>;
fn can_be_v0(&self) -> bool;
fn is_v0(&self) -> bool;
fn is_v1(&self) -> bool;
fn codec_code(&self) -> u64;
fn hash_algorithm_name(&self) -> &'static str;
fn hash_algorithm_code(&self) -> u64;
}Expand description
Extension trait for CID with additional encoding utilities
Required Methods§
Sourcefn to_string_with_base(&self, base: MultibaseEncoding) -> String
fn to_string_with_base(&self, base: MultibaseEncoding) -> String
Encode the CID to a string with the specified multibase encoding
Sourcefn to_v1(&self) -> Result<Cid>
fn to_v1(&self) -> Result<Cid>
Convert CIDv0 to CIDv1
CIDv0 is converted to CIDv1 with DAG-PB codec (0x70)
Sourcefn to_v0(&self) -> Result<Cid>
fn to_v0(&self) -> Result<Cid>
Try to convert CIDv1 to CIDv0
This only succeeds if:
- The hash algorithm is SHA2-256
- The codec is DAG-PB (0x70)
Sourcefn can_be_v0(&self) -> bool
fn can_be_v0(&self) -> bool
Check if this CID can be represented as CIDv0
Returns true if the CID uses SHA2-256 and DAG-PB codec
Sourcefn codec_code(&self) -> u64
fn codec_code(&self) -> u64
Get the codec code
Sourcefn hash_algorithm_name(&self) -> &'static str
fn hash_algorithm_name(&self) -> &'static str
Get the hash algorithm name
Sourcefn hash_algorithm_code(&self) -> u64
fn hash_algorithm_code(&self) -> u64
Get the hash algorithm code