BlobHeader

Struct BlobHeader 

Source
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

Source

pub fn get_blob_size(&self) -> usize

Returns the original byte length of the blob data before padding.

Source

pub fn get_num_chunksets(&self) -> usize

Returns the total number of chunksets that comprise the blob.

Source

pub fn get_num_chunks(&self) -> usize

Returns the total number of erasure-coded chunks across all chunksets in the blob.

Source

pub fn get_blob_digest(&self) -> Hash

Returns the BLAKE3 digest of the original, unpadded blob data.

Source

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.

Source

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) if chunkset_id is out of bounds.
Source

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) if chunkset_id is out of bounds.
Source

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) if chunkset_id is out of bounds.
Source

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 range impl 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 an Excluded bound or usize::MAX).
  • Err(DecdsError::InvalidChunksetId) if the calculated end_chunkset_id is out of bounds.
Source

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) if bincode serialization fails.
Source

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 deserialized BlobHeader and the number of bytes read if successful.
  • Err(DecdsError::BlobHeaderDeserializationFailed) if bincode deserialization fails, or if the number of chunksets in the header does not match the number of root commitments.
Source

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 the ProofCarryingChunk to 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

Source§

fn clone(&self) -> BlobHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BlobHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BlobHeader

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for BlobHeader

Source§

fn eq(&self, other: &BlobHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BlobHeader

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BlobHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,