Skip to main content

Packer

Struct Packer 

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

Puts samples into data datagrams, with copies of the samples before them. docs/extensions.md, section dgram, the copies.

The packer works on encoded samples, so it needs no codec. Each sample must carry its full timestamp.

Implementations§

Source§

impl Packer

Source

pub fn new(cookie: u64) -> Packer

A packer for the connection with this cookie. It starts with no copies.

Source

pub fn copies(&self) -> u8

The count of copies of each sample.

Source

pub fn serial(&self) -> u32

The serial of the next data datagram.

Source

pub fn set_copies(&mut self, copies: u8)

Set the count of copies of each sample, at most MAX_COPIES.

Source

pub fn resend( &mut self, first: u64, samples: &[Vec<u8>], out: &mut Vec<Vec<u8>>, )

Put samples of a resend into data datagrams with no copies. samples holds encoded samples with consecutive numbers from first. A sample too large for a datagram is left out.

Source

pub fn push_slices( &mut self, first: u64, samples: &[&[u8]], gram: &mut Vec<u8>, on_datagram: impl FnMut(&[u8]), on_tcp: impl FnMut(u64), )

Put the samples of one push into packets, from slices in one buffer. The caller reuses gram, and on_datagram or on_tcp runs for each packet. When copies is 0, no sample goes into the copy buffer.

Source

pub fn push(&mut self, first: u64, samples: &[Vec<u8>], out: &mut Vec<Packet>)

Put the samples of one push into packets. samples holds encoded samples with consecutive numbers from first.

The new samples fill each datagram first. The free space then takes copies of the samples just before them, newest first, so that the samples of a datagram stay consecutive. Each sample goes into at most 1 + copies datagrams.

Source

pub fn repeat(&mut self) -> Option<Vec<u8>>

A datagram with copies of the last samples and no new sample, or None when each recent sample has all its copies. The outlet sends it when no data datagram follows for 5 ms.

Trait Implementations§

Source§

impl Debug for Packer

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Packer

§

impl Freeze for Packer

§

impl Move for Packer

§

impl RefUnwindSafe for Packer

§

impl Send for Packer

§

impl Sync for Packer

§

impl Unpin for Packer

§

impl UnsafeUnpin for Packer

§

impl UnwindSafe for Packer

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.