Skip to main content

BitArray

Struct BitArray 

Source
pub struct BitArray { /* private fields */ }
Expand description

A 128-bit mask, indexed from the most significant bit.

Bit 0 is the most significant bit, matching how FlexFEC packet masks are laid out on the wire: the first media packet after the base sequence number is the leftmost bit. Upstream keeps this as a Lo/Hi pair of u64s; a single u128 is the same bits with the seam removed.

Implementations§

Source§

impl BitArray

Source

pub fn new() -> Self

An empty mask.

Source

pub fn set_bit(&mut self, index: u32)

Set the bit at index, counting from the most significant.

Out-of-range indices are ignored rather than panicking: coverage is computed from packet counts that are already bounded, so a stray index means a caller bug, not a packet the mask should silently mis-cover.

Source

pub fn bit(&self, index: u32) -> bool

Whether the bit at index is set.

Source

pub fn reset(&mut self)

Clear every bit.

Source

pub fn is_empty(&self) -> bool

Whether no bits are set.

Source

pub fn mask1(&self) -> u16

The 15-bit mask covering media packets 0..=14 — the one always present on the wire.

Source

pub fn mask2(&self) -> u32

The 31-bit mask covering media packets 15..=45, present when the first k-bit is clear.

Source

pub fn mask3(&self) -> u64

The 64-bit mask covering media packets 46..=109, as RFC 8627 lays it out.

Source

pub fn mask3_draft03(&self) -> u64

The draft-03 variant of mask3: 63 bits rather than 64.

Draft-03 spends one more bit on the k-flag than the published RFC does, so the third mask is one bit narrower and the whole field shifts down by one. This is the single most consequential difference between the two formats at the bit level, and the reason a draft-03 round trip proves nothing about RFC 8627 conformance.

Trait Implementations§

Source§

impl Clone for BitArray

Source§

fn clone(&self) -> BitArray

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 BitArray

Source§

impl Debug for BitArray

Source§

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

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

impl Default for BitArray

Source§

fn default() -> BitArray

Returns the “default value” for a type. Read more
Source§

impl Eq for BitArray

Source§

impl PartialEq for BitArray

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BitArray

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.