mls_spec/group/
commits.rs

1use crate::{
2    group::{ProposalRef, proposals::Proposal},
3    tree::UpdatePath,
4};
5
6/// <https://www.rfc-editor.org/rfc/rfc9420.html#section-12.4-3>
7///
8/// ### TLS Presentation Language
9///
10/// ```notrust,ignore
11/// enum {
12///   reserved(0),
13///   proposal(1),
14///   reference(2),
15///   (255)
16/// } ProposalOrRefType;
17/// ```
18#[derive(
19    Debug,
20    Clone,
21    Copy,
22    PartialEq,
23    Eq,
24    tls_codec::TlsSerialize,
25    tls_codec::TlsDeserialize,
26    tls_codec::TlsSize,
27)]
28#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
29#[repr(u8)]
30pub enum ProposalOrRefType {
31    Reserved = 0x00,
32    Proposal = 0x01,
33    Reference = 0x02,
34}
35
36/// <https://www.rfc-editor.org/rfc/rfc9420.html#section-12.4-3>
37///
38/// ### TLS Presentation Language
39///
40/// ```notrust,ignore
41/// struct {
42///   ProposalOrRefType type;
43///   select (ProposalOrRef.type) {
44///     case proposal:  Proposal proposal;
45///     case reference: ProposalRef reference;
46///   };
47/// } ProposalOrRef;
48/// ```
49#[derive(
50    Debug,
51    Clone,
52    PartialEq,
53    Eq,
54    tls_codec::TlsSerialize,
55    tls_codec::TlsDeserialize,
56    tls_codec::TlsSize,
57)]
58#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
59#[repr(u8)]
60#[allow(clippy::large_enum_variant)]
61pub enum ProposalOrRef {
62    #[tls_codec(discriminant = "ProposalOrRefType::Proposal")]
63    Proposal(Proposal),
64    #[tls_codec(discriminant = "ProposalOrRefType::Reference")]
65    Reference(ProposalRef),
66}
67
68/// A MLS Commit contains the modifications applied to a group
69/// for an epoch N to epoch N + 1 transition
70///
71/// <https://www.rfc-editor.org/rfc/rfc9420.html#section-12.4-3>
72///
73/// ### TLS Presentation Language
74///
75/// ```notrust,ignore
76/// struct {
77///     ProposalOrRef proposals<V>;
78///     optional<UpdatePath> path;
79/// } Commit;
80/// ```
81#[derive(
82    Debug,
83    Clone,
84    PartialEq,
85    Eq,
86    tls_codec::TlsSerialize,
87    tls_codec::TlsDeserialize,
88    tls_codec::TlsSize,
89)]
90#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
91pub struct Commit {
92    pub proposals: Vec<ProposalOrRef>,
93    pub path: Option<UpdatePath>,
94}