Skip to main content

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(
29    feature = "serde",
30    derive(serde_repr::Serialize_repr, serde_repr::Deserialize_repr)
31)]
32#[repr(u8)]
33pub enum ProposalOrRefType {
34    Reserved = 0x00,
35    Proposal = 0x01,
36    Reference = 0x02,
37}
38
39/// <https://www.rfc-editor.org/rfc/rfc9420.html#section-12.4-3>
40///
41/// ### TLS Presentation Language
42///
43/// ```notrust,ignore
44/// struct {
45///   ProposalOrRefType type;
46///   select (ProposalOrRef.type) {
47///     case proposal:  Proposal proposal;
48///     case reference: ProposalRef reference;
49///   };
50/// } ProposalOrRef;
51/// ```
52#[derive(
53    Debug,
54    Clone,
55    PartialEq,
56    Eq,
57    tls_codec::TlsSerialize,
58    tls_codec::TlsDeserialize,
59    tls_codec::TlsSize,
60)]
61#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
62#[repr(u8)]
63#[allow(clippy::large_enum_variant)]
64pub enum ProposalOrRef {
65    #[tls_codec(discriminant = "ProposalOrRefType::Proposal")]
66    Proposal(Proposal),
67    #[tls_codec(discriminant = "ProposalOrRefType::Reference")]
68    Reference(ProposalRef),
69}
70
71/// A MLS Commit contains the modifications applied to a group
72/// for an epoch N to epoch N + 1 transition
73///
74/// <https://www.rfc-editor.org/rfc/rfc9420.html#section-12.4-3>
75///
76/// ### TLS Presentation Language
77///
78/// ```notrust,ignore
79/// struct {
80///     ProposalOrRef proposals<V>;
81///     optional<UpdatePath> path;
82/// } Commit;
83/// ```
84#[derive(
85    Debug,
86    Clone,
87    PartialEq,
88    Eq,
89    tls_codec::TlsSerialize,
90    tls_codec::TlsDeserialize,
91    tls_codec::TlsSize,
92)]
93#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
94pub struct Commit {
95    pub proposals: Vec<ProposalOrRef>,
96    pub path: Option<UpdatePath>,
97}