pub struct Producer { /* private fields */ }Expand description
Exclusive producer for one physical track.
Owns the grouped-frame and datagram keys and the shared sequence namespace. Sequences are allocated monotonically; reuse and exhaustion are refused before encryption.
Implementations§
Source§impl Producer
impl Producer
Sourcepub fn append_group(&mut self) -> Result<Producer>
pub fn append_group(&mut self) -> Result<Producer>
Allocate the next sequence and start a group there.
§Errors
Error::Identity if the next sequence exceeds 2^53-1, or a net error.
Sourcepub fn create_group(&mut self, sequence: u64) -> Result<Producer>
pub fn create_group(&mut self, sequence: u64) -> Result<Producer>
Start a group at an explicit sequence, which must be at or above the next unallocated one.
§Errors
Error::Reuse if sequence was already allocated, Error::Identity if
it exceeds 2^53-1, or a net error.
Sourcepub fn append_datagram(
&mut self,
timestamp: Timestamp,
plaintext: &[u8],
) -> Result<u64>
pub fn append_datagram( &mut self, timestamp: Timestamp, plaintext: &[u8], ) -> Result<u64>
Encrypt plaintext at the next sequence and insert the datagram, returning that sequence.
§Errors
Error::Identity, Error::Exhausted, Error::Oversize, or a net write error.
Sourcepub fn insert_datagram(
&mut self,
sequence: u64,
timestamp: Timestamp,
plaintext: &[u8],
) -> Result<()>
pub fn insert_datagram( &mut self, sequence: u64, timestamp: Timestamp, plaintext: &[u8], ) -> Result<()>
Encrypt plaintext at an explicit sequence and insert the datagram.
Plaintext is capped at MAX_DATAGRAM_PLAINTEXT.
A predictable failure is refused before the sequence is allocated; once
encrypted, the identity is spent even if the net write fails.
§Errors
Error::Reuse if sequence was already allocated, Error::Identity,
Error::Exhausted, Error::Oversize, or a net write error.