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
impl Packer
Sourcepub fn new(cookie: u64) -> Packer
pub fn new(cookie: u64) -> Packer
A packer for the connection with this cookie. It starts with no copies.
Sourcepub fn set_copies(&mut self, copies: u8)
pub fn set_copies(&mut self, copies: u8)
Set the count of copies of each sample, at most MAX_COPIES.
Sourcepub fn resend(
&mut self,
first: u64,
samples: &[Vec<u8>],
out: &mut Vec<Vec<u8>>,
)
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.
Sourcepub fn push_slices(
&mut self,
first: u64,
samples: &[&[u8]],
gram: &mut Vec<u8>,
on_datagram: impl FnMut(&[u8]),
on_tcp: impl FnMut(u64),
)
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.
Sourcepub fn push(&mut self, first: u64, samples: &[Vec<u8>], out: &mut Vec<Packet>)
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.