Skip to main content

SourceBlockPartition

Struct SourceBlockPartition 

Source
pub struct SourceBlockPartition {
    pub transfer_length: u64,
    pub encoding_symbol_length: u32,
    pub source_symbols: u64,
    pub num_blocks: u64,
    pub larger_block_len: u64,
    pub smaller_block_len: u64,
    pub larger_blocks: u64,
}
Expand description

The source-block structure of a transport object, per RFC 5052 §9.1’s Block Partitioning Algorithm.

Given a transport object of transfer_length octets (L), an encoding_symbol_length (E) and a max_source_block_length (B), RFC 5052 splits the object into num_blocks (N) source blocks: the first larger_blocks (I) blocks each have larger_block_len (A_large) source symbols, and the remaining num_blocks - larger_blocks blocks each have smaller_block_len (A_small) source symbols. Every source symbol is E octets, except the very last source symbol of the very last source block (Self::last_symbol_len).

All three inputs are RFC 5052 Common FEC OTI elements (§6.2.4) — this type does not read wire bytes; the caller supplies them from wherever the CDP carried them (ALC’s EXT_FTI, a FLUTE FDT attribute, …).

Fields§

§transfer_length: u64

The transport object length in octets (L, Transfer-Length).

§encoding_symbol_length: u32

The encoding symbol length in octets (E, Encoding-Symbol-Length).

§source_symbols: u64

Total source symbols in the object (T = ceil(L / E)).

§num_blocks: u64

Number of source blocks (N = ceil(T / B)).

§larger_block_len: u64

Source symbols in each of the first larger_blocks blocks (A_large = ceil(T / N)).

§smaller_block_len: u64

Source symbols in each of the remaining blocks (A_small = floor(T / N)).

§larger_blocks: u64

Number of “larger” blocks (I = T - A_small * N).

Implementations§

Source§

impl SourceBlockPartition

Source

pub fn new( transfer_length: u64, encoding_symbol_length: u32, max_source_block_length: u32, ) -> Result<Self>

Apply RFC 5052 §9.1’s Block Partitioning Algorithm.

transfer_length is the transport object length in octets (L), encoding_symbol_length is E, and max_source_block_length is B.

A zero-length object (transfer_length == 0) yields zero source symbols and zero source blocks — RFC 5052’s ceiling division treats ceil(0/E) as 0, not 1.

§Errors

Returns Error::InvalidField if encoding_symbol_length or max_source_block_length is 0 (both are divisors in the algorithm; RFC 5052 gives no meaning to either being zero).

Source

pub fn block_len(&self, index: u64) -> Option<u64>

Number of source symbols in source block index (0-based), or None if index >= num_blocks.

The first larger_blocks blocks (indices 0..larger_blocks) each have larger_block_len symbols; the remaining blocks have smaller_block_len.

Source

pub fn last_symbol_len(&self) -> Option<u32>

Length in octets of the very last source symbol of the very last source block (RFC 5052 §9.1: L - floor((L-1)/E)*E) — the object’s actual trailing remainder, since L is not generally an exact multiple of E. None if the object has zero source symbols (there is no “last symbol” to speak of).

Trait Implementations§

Source§

impl Clone for SourceBlockPartition

Source§

fn clone(&self) -> SourceBlockPartition

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for SourceBlockPartition

Source§

impl Debug for SourceBlockPartition

Source§

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

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

impl Eq for SourceBlockPartition

Source§

impl Hash for SourceBlockPartition

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SourceBlockPartition

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for SourceBlockPartition

Available on crate feature serde only.
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 SourceBlockPartition

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