pub struct CidBuilder { /* private fields */ }Expand description
CID builder for creating content identifiers
Implementations§
Source§impl CidBuilder
impl CidBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new CidBuilder with default settings.
Uses CIDv1, raw codec (0x55), and SHA2-256 hash algorithm by default.
Sourcepub fn v0() -> Self
pub fn v0() -> Self
Create a builder configured for CIDv0 (legacy IPFS format)
CIDv0 uses:
- SHA2-256 hash algorithm
- DAG-PB codec (0x70)
- Base58btc encoding (implicit, starts with “Qm”)
Sourcepub fn version(self, version: Version) -> Self
pub fn version(self, version: Version) -> Self
Sets the CID version (V0 or V1).
Note: CIDv0 has restrictions (must use SHA2-256 and DAG-PB codec).
Sourcepub fn codec(self, codec: u64) -> Self
pub fn codec(self, codec: u64) -> Self
Sets the codec for the CID.
Common codecs:
0x55- raw binary0x70- DAG-PB (IPFS DAG protobuf)0x71- DAG-CBOR0x0129- DAG-JSON
Sourcepub fn hash_algorithm(self, algorithm: HashAlgorithm) -> Self
pub fn hash_algorithm(self, algorithm: HashAlgorithm) -> Self
Sets the hash algorithm to use for CID generation.
Supported algorithms: SHA2-256, SHA3-256, BLAKE3.
Sourcepub fn build(&self, data: &[u8]) -> Result<Cid>
pub fn build(&self, data: &[u8]) -> Result<Cid>
Build a CID from data using the configured hash algorithm
Sourcepub fn build_dag_cbor(&self, data: &[u8]) -> Result<Cid>
pub fn build_dag_cbor(&self, data: &[u8]) -> Result<Cid>
Build a CID using DAG-CBOR codec
Trait Implementations§
Source§impl Clone for CidBuilder
impl Clone for CidBuilder
Source§fn clone(&self) -> CidBuilder
fn clone(&self) -> CidBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CidBuilder
impl Debug for CidBuilder
Auto Trait Implementations§
impl Freeze for CidBuilder
impl RefUnwindSafe for CidBuilder
impl Send for CidBuilder
impl Sync for CidBuilder
impl Unpin for CidBuilder
impl UnwindSafe for CidBuilder
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<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