Struct blob_stream::BlobStreamIn

source ·
pub struct BlobStreamIn { /* private fields */ }
Expand description

A struct representing a stream of binary data divided into fixed-size chunks.

Implementations§

source§

impl BlobStreamIn

source

pub fn new(octet_count: usize, fixed_chunk_size: usize) -> Self

Creates a new BlobStreamIn instance with the specified number of octets and chunk size.

§Parameters
  • octet_count: The total number of octets (bytes) in the stream.
  • fixed_chunk_size: The size of each chunk in the stream.
§Panics

Panics if fixed_chunk_size is zero.

§Returns

A new BlobStreamIn instance.

source

pub const fn chunk_count(&self) -> usize

Returns the total number of expected chunks.

This function provides the total count of chunks that are expected based on the size of the data and the chunk size.

§Returns

The total number of chunks (usize) that are expected for the data.

source

pub const fn is_complete(&self) -> bool

Checks if all chunks have been received.

§Returns

true if all chunks have been received; false otherwise.

source

pub fn blob(&self) -> Option<&[u8]>

Returns a reference to the complete blob if all chunks have been received.

§Returns

An Option containing a reference to the blob if complete; otherwise, None.

source

pub fn set_chunk( &mut self, chunk_index: usize, payload: &[u8], ) -> Result<(), BlobError>

Sets a chunk of data at the specified chunk_index with the provided payload.

§Parameters
  • chunk_index: The index of the chunk to set.
  • payload: A slice of octets representing the chunk’s data.
§Errors

Returns a BlobError if:

  • The chunk_index is invalid.
  • The payload size does not match the expected size for the chunk.
  • The chunk has already been set, with either the same or different contents.
§Returns

Ok(()) if the chunk was set successfully; otherwise, a BlobError.

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> 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, 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.