Skip to main content

moq_e2ee/
datagram.rs

1//! Decrypted datagrams and the events a protected datagram read yields.
2
3use bytes::Bytes;
4
5/// A decrypted datagram.
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub struct Datagram {
8	/// Per-track sequence, shared with the group namespace.
9	pub sequence: u64,
10	/// Presentation timestamp.
11	pub timestamp: moq_net::Timestamp,
12	/// Decrypted application bytes.
13	pub plaintext: Bytes,
14}
15
16/// Outcome of reading one protected datagram.
17#[derive(Clone, Debug, PartialEq, Eq)]
18pub enum Event {
19	/// Authenticated plaintext.
20	Datagram(Datagram),
21	/// AEAD open failed; the datagram was dropped and the track continues.
22	Authentication {
23		/// Sequence of the rejected datagram.
24		sequence: u64,
25	},
26	/// Sequence already opened inside the retained window; dropped, track continues.
27	Duplicate {
28		/// Sequence of the duplicate datagram.
29		sequence: u64,
30	},
31}