Skip to main content

Reorder

Struct Reorder 

Source
pub struct Reorder<T> { /* private fields */ }
Expand description

Puts the samples of two paths back in the order of their numbers. docs/extensions.md, section dgram, the resend and the count on two paths.

The buffer gives each number once, in order. A gap at the expected number waits for a copy, then for a resend, then counts as lost. Time is a value in seconds that the caller gives, so the buffer needs no clock.

Implementations§

Source§

impl<T> Reorder<T>

Source

pub fn new() -> Self

An empty buffer with no expected number.

Source

pub fn start(&mut self, number: u64)

Set the expected number, if the buffer has none yet.

Source

pub fn set_small_gaps(&mut self, max: u64, give_up: f64)

Repair each gap of at most max samples on UDP: Reorder::nacks gives them, Reorder::poll asks for none of them on TCP, and gives one up at the expected number give_up seconds after it showed.

Source

pub fn rtt(&self) -> Option<f64>

The round trip of a resend on UDP, once measured.

Source

pub fn has_gaps(&self) -> bool

True when the buffer holds a sample above the expected number, or knows of a sample above it.

Source

pub fn nacks(&mut self, now: f64, wait: f64) -> Vec<(u64, u32)>

The small gaps to ask for on UDP now: each gap that stayed for wait seconds, again each max(10 ms, 1.5 x round trip) until it closes. At most MAX_GAPS gaps, from the lowest.

Source

pub fn expected(&self) -> Option<u64>

The number that the buffer gives next.

Source

pub fn lost(&self) -> u64

The count of numbers that the buffer gave up.

Source

pub fn duplicates(&self) -> u64

The count of samples that arrived again, or too late.

Source

pub fn insert_or_emit(&mut self, number: u64, item: T, out: &mut Vec<T>) -> bool

Take one sample from either path. When the sample is next in order and no sample waits in the buffer, it goes directly to out.

Source

pub fn insert(&mut self, number: u64, item: T) -> bool

Take one sample from either path. The result is false for a sample that the buffer already has, or that it gave up.

Source

pub fn idle(&mut self, next: u64)

An idle datagram: the next sample of the outlet gets next.

Source

pub fn udp_heard(&mut self, now: f64)

A datagram arrived on UDP at now. A small gap is given up only while datagrams still arrive, so a cut does not drop a sample before resume/1 can ask for it.

Source

pub fn lost_below(&mut self, number: u64)

The outlet has no sample below number for this inlet: a resend started at number. The numbers from the expected number up to it count as lost. docs/extensions.md, resend rule 5.

Source

pub fn progress(&mut self, now: f64)

Data arrived on TCP at now. A resend can be slow on a slow link, so the time limit of an open request counts again from this point. docs/extensions.md, section dgram, resend rule 6.

Source

pub fn assume_requested(&mut self, from: u64, until: u64, now: f64)

The numbers from..until are on the way on TCP, as at the start of a connection with a resume resend. The buffer asks for none of them.

Source

pub fn drain(&mut self, out: &mut Vec<T>) -> usize

Move each sample that follows the expected number to out, in order. The result is their count.

Source

pub fn poll(&mut self, now: f64, wait: f64, give_up: f64) -> Option<Action>

Check the gap at the expected number. Call it after each Reorder::drain.

A gap that stays for wait seconds gives a request. A request with no answer for give_up seconds gives up the gap: its numbers count as lost, and the samples after it can go.

Trait Implementations§

Source§

impl<T: Debug> Debug for Reorder<T>

Source§

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

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

impl<T> Default for Reorder<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> Forget for Reorder<T>

§

impl<T> Freeze for Reorder<T>
where BTreeMap<u64, T>: Freeze,

§

impl<T> Move for Reorder<T>

§

impl<T> RefUnwindSafe for Reorder<T>

§

impl<T> Send for Reorder<T>
where BTreeMap<u64, T>: Send,

§

impl<T> Sync for Reorder<T>
where BTreeMap<u64, T>: Sync,

§

impl<T> Unpin for Reorder<T>
where BTreeMap<u64, T>: Unpin,

§

impl<T> UnsafeUnpin for Reorder<T>

§

impl<T> UnwindSafe for Reorder<T>
where BTreeMap<u64, T>: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.