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: u64The transport object length in octets (L, Transfer-Length).
encoding_symbol_length: u32The encoding symbol length in octets (E, Encoding-Symbol-Length).
source_symbols: u64Total source symbols in the object (T = ceil(L / E)).
num_blocks: u64Number of source blocks (N = ceil(T / B)).
larger_block_len: u64Source symbols in each of the first larger_blocks blocks
(A_large = ceil(T / N)).
smaller_block_len: u64Source symbols in each of the remaining blocks
(A_small = floor(T / N)).
larger_blocks: u64Number of “larger” blocks (I = T - A_small * N).
Implementations§
Source§impl SourceBlockPartition
impl SourceBlockPartition
Sourcepub fn new(
transfer_length: u64,
encoding_symbol_length: u32,
max_source_block_length: u32,
) -> Result<Self>
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).
Sourcepub fn block_len(&self, index: u64) -> Option<u64>
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.
Sourcepub fn last_symbol_len(&self) -> Option<u32>
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
impl Clone for SourceBlockPartition
Source§fn clone(&self) -> SourceBlockPartition
fn clone(&self) -> SourceBlockPartition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SourceBlockPartition
Source§impl Debug for SourceBlockPartition
impl Debug for SourceBlockPartition
impl Eq for SourceBlockPartition
Source§impl Hash for SourceBlockPartition
impl Hash for SourceBlockPartition
Source§impl PartialEq for SourceBlockPartition
impl PartialEq for SourceBlockPartition
Source§impl Serialize for SourceBlockPartition
Available on crate feature serde only.
impl Serialize for SourceBlockPartition
serde only.