pub struct BlockBuilder { /* private fields */ }Expand description
Builder for creating blocks with custom CID settings.
Use this when you need to specify a custom hash algorithm, CID version, or codec.
§Example
use ipfrs_core::{Block, HashAlgorithm, cid::codec};
use bytes::Bytes;
let block = Block::builder()
.hash_algorithm(HashAlgorithm::Sha3_256)
.codec(codec::DAG_CBOR)
.build(Bytes::from_static(b"data"))
.unwrap();Implementations§
Source§impl BlockBuilder
impl BlockBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new BlockBuilder with default settings.
Uses SHA2-256 hash algorithm and CIDv1 by default.
Sourcepub fn hash_algorithm(self, algorithm: HashAlgorithm) -> Self
pub fn hash_algorithm(self, algorithm: HashAlgorithm) -> Self
Set the hash algorithm to use
Sourcepub fn cid_version(self, version: Version) -> Self
pub fn cid_version(self, version: Version) -> Self
Set the CID version
Sourcepub fn build_from_slice(self, data: &[u8]) -> Result<Block>
pub fn build_from_slice(self, data: &[u8]) -> Result<Block>
Build a block from data slice (convenience method)
Trait Implementations§
Source§impl Clone for BlockBuilder
impl Clone for BlockBuilder
Source§fn clone(&self) -> BlockBuilder
fn clone(&self) -> BlockBuilder
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 BlockBuilder
impl Debug for BlockBuilder
Auto Trait Implementations§
impl Freeze for BlockBuilder
impl RefUnwindSafe for BlockBuilder
impl Send for BlockBuilder
impl Sync for BlockBuilder
impl Unpin for BlockBuilder
impl UnwindSafe for BlockBuilder
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