pub struct Block { /* private fields */ }Expand description
Block
Implementations§
Source§impl Block
impl Block
Sourcepub fn new(cid: Cid, data: Vec<u8>) -> Result<Self, BlockError>
pub fn new(cid: Cid, data: Vec<u8>) -> Result<Self, BlockError>
Creates a new block. Returns an error if the hash doesn’t match the data.
Sourcepub fn new_unchecked(cid: Cid, data: Vec<u8>) -> Self
pub fn new_unchecked(cid: Cid, data: Vec<u8>) -> Self
Creates a new block without verifying the cid.
Sourcepub fn new_data(codec: impl Into<u64>, data: Vec<u8>) -> Self
pub fn new_data(codec: impl Into<u64>, data: Vec<u8>) -> Self
Create a new block by calculating the Cid from data using the default hasher.
Note: The default hasher may changes without notice.
Sourcepub fn new_data_digest(
digest: impl MultihashDigest<64>,
codec: impl Into<u64>,
data: Vec<u8>,
) -> Self
pub fn new_data_digest( digest: impl MultihashDigest<64>, codec: impl Into<u64>, data: Vec<u8>, ) -> Self
Create a new block by calculating the Cid from data.
pub fn cid_data(codec: impl Into<u64>, data: &[u8]) -> Cid
pub fn cid_data_digest( digest: impl MultihashDigest<64>, codec: impl Into<u64>, data: &[u8], ) -> Cid
Sourcepub fn into_inner(self) -> (Cid, Vec<u8>)
pub fn into_inner(self) -> (Cid, Vec<u8>)
Returns the inner cid and data.
Sourcepub fn with_verify(self) -> Result<Block, BlockError>
pub fn with_verify(self) -> Result<Block, BlockError>
Block with verified hash.
Sourcepub fn with_store_params<P: StoreParams>(self) -> Result<Block, BlockError>
pub fn with_store_params<P: StoreParams>(self) -> Result<Block, BlockError>
Block with specific store params.
Sourcepub fn with_block_max_size(
self,
max_block_size: usize,
) -> Result<Block, BlockError>
pub fn with_block_max_size( self, max_block_size: usize, ) -> Result<Block, BlockError>
Block with specific store max size.
Trait Implementations§
Source§impl Ord for Block
impl Ord for Block
Source§impl PartialOrd for Block
impl PartialOrd for Block
impl Eq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
impl UnwindSafe for Block
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