pub struct BlobHeader { /* private fields */ }Expand description
Represents the header of a Blob, containing essential metadata about the blob’s
structure and cryptographic commitments. This is essentially what is used during
validity checking and repairing of erasure-coded chunks.
Implementations§
Source§impl BlobHeader
impl BlobHeader
Sourcepub fn get_blob_size(&self) -> usize
pub fn get_blob_size(&self) -> usize
Returns the original byte length of the blob data before padding.
Sourcepub fn get_num_chunksets(&self) -> usize
pub fn get_num_chunksets(&self) -> usize
Returns the total number of chunksets that comprise the blob.
Sourcepub fn get_num_chunks(&self) -> usize
pub fn get_num_chunks(&self) -> usize
Returns the total number of erasure-coded chunks across all chunksets in the blob.
Sourcepub fn get_blob_digest(&self) -> Hash
pub fn get_blob_digest(&self) -> Hash
Returns the BLAKE3 digest of the original, unpadded blob data.
Sourcepub fn get_root_commitment(&self) -> Hash
pub fn get_root_commitment(&self) -> Hash
Returns the Merkle root commitment of the entire blob.
This commitment is derived from the Merkle tree of all chunksets in the blob.
Sourcepub fn get_chunkset_commitment(
&self,
chunkset_id: usize,
) -> Result<Hash, DecdsError>
pub fn get_chunkset_commitment( &self, chunkset_id: usize, ) -> Result<Hash, DecdsError>
Returns the Merkle root commitment of a specific chunkset within the blob.
§Arguments
chunkset_id- The ID of the chunkset whose commitment is to be retrieved.
§Returns
Returns a Result which is:
Ok(blake3::Hash)containing the root commitment of the specified chunkset if successful.Err(DecdsError::InvalidChunksetId)ifchunkset_idis out of bounds.
Sourcepub fn get_chunkset_size(&self, chunkset_id: usize) -> Result<usize, DecdsError>
pub fn get_chunkset_size(&self, chunkset_id: usize) -> Result<usize, DecdsError>
Calculates the effective byte length of a specific chunkset within the blob.
This accounts for the last chunkset potentially being smaller than ChunkSet::BYTE_LENGTH.
§Arguments
chunkset_id- The ID of the chunkset whose size is to be determined.
§Returns
Returns a Result which is:
Ok(usize)containing the effective byte length of the chunkset if successful.Err(DecdsError::InvalidChunksetId)ifchunkset_idis out of bounds.
Sourcepub fn get_byte_range_for_chunkset(
&self,
chunkset_id: usize,
) -> Result<(usize, usize), DecdsError>
pub fn get_byte_range_for_chunkset( &self, chunkset_id: usize, ) -> Result<(usize, usize), DecdsError>
Returns the full byte range [start, end) of a specific chunkset as it would appear
in the zero-padded blob data.
§Arguments
chunkset_id- The ID of the chunkset whose byte range is to be retrieved.
§Returns
Returns a Result which is:
Ok((usize, usize))containing a tuple[start_byte_idx, end_byte_idx)if successful.Err(DecdsError::InvalidChunksetId)ifchunkset_idis out of bounds.
Sourcepub fn get_chunkset_ids_for_byte_range(
&self,
byte_range: impl RangeBounds<usize>,
) -> Result<Vec<usize>, DecdsError>
pub fn get_chunkset_ids_for_byte_range( &self, byte_range: impl RangeBounds<usize>, ) -> Result<Vec<usize>, DecdsError>
Determines the IDs of all chunksets that overlap with a given byte range within the blob.
§Arguments
byte_range- A rangeimpl RangeBounds<usize>specifying the byte range.
§Returns
Returns a Result which is:
Ok(Vec<usize>)containing a vector of chunkset IDs if successful.Err(DecdsError::InvalidStartBound)if the start bound of the range is not valid.Err(DecdsError::InvalidEndBound)if the end bound of the range is not valid (e.g., 0 for anExcludedbound orusize::MAX).Err(DecdsError::InvalidChunksetId)if the calculatedend_chunkset_idis out of bounds.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, DecdsError>
pub fn to_bytes(&self) -> Result<Vec<u8>, DecdsError>
Serializes the BlobHeader into a vector of bytes using bincode.
§Returns
Returns a Result which is:
Ok(Vec<u8>)containing the serialized bytes if successful.Err(DecdsError::BlobHeaderSerializationFailed)ifbincodeserialization fails.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize), DecdsError>
pub fn from_bytes(bytes: &[u8]) -> Result<(Self, usize), DecdsError>
Deserializes a BlobHeader from a byte slice using bincode.
§Arguments
bytes- The byte slice from which to deserialize the header.
§Returns
Returns a Result which is:
Ok((Self, usize))containing the deserializedBlobHeaderand the number of bytes read if successful.Err(DecdsError::BlobHeaderDeserializationFailed)ifbincodedeserialization fails, or if the number of chunksets in the header does not match the number of root commitments.
Sourcepub fn validate_chunk(&self, chunk: &ProofCarryingChunk) -> bool
pub fn validate_chunk(&self, chunk: &ProofCarryingChunk) -> bool
Validates a ProofCarryingChunk against the BlobHeader’s commitments.
This checks if the chunk is correctly included in the blob (via blob root commitment) and its respective chunkset (via chunkset root commitment).
§Arguments
chunk- A reference to theProofCarryingChunkto validate.
§Returns
Returns true if the chunk is valid and its proofs are consistent with the blob header, false otherwise.
Trait Implementations§
Source§impl Clone for BlobHeader
impl Clone for BlobHeader
Source§fn clone(&self) -> BlobHeader
fn clone(&self) -> BlobHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlobHeader
impl Debug for BlobHeader
Source§impl<'de> Deserialize<'de> for BlobHeader
impl<'de> Deserialize<'de> for BlobHeader
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for BlobHeader
impl PartialEq for BlobHeader
Source§impl Serialize for BlobHeader
impl Serialize for BlobHeader
impl StructuralPartialEq for BlobHeader
Auto Trait Implementations§
impl Freeze for BlobHeader
impl RefUnwindSafe for BlobHeader
impl Send for BlobHeader
impl Sync for BlobHeader
impl Unpin for BlobHeader
impl UnwindSafe for BlobHeader
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
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>
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>
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