• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // Copyright by contributors to this project.
3 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
4 
5 use alloc::vec::Vec;
6 use mls_rs_codec::MlsEncode;
7 pub use mls_rs_core::group::{EpochRecord, GroupState};
8 
9 use crate::group::snapshot::Snapshot;
10 
11 #[cfg(feature = "prior_epoch")]
12 use crate::group::epoch::PriorEpoch;
13 
14 #[cfg(feature = "prior_epoch")]
15 impl EpochRecord for PriorEpoch {
id(&self) -> u6416     fn id(&self) -> u64 {
17         self.epoch_id()
18     }
19 }
20 
21 impl GroupState for Snapshot {
id(&self) -> Vec<u8>22     fn id(&self) -> Vec<u8> {
23         self.group_id().to_vec()
24     }
25 }
26 
27 #[derive(Debug, Clone, PartialEq, Eq)]
28 pub(crate) struct EpochData {
29     pub(crate) id: u64,
30     pub(crate) data: Vec<u8>,
31 }
32 
33 impl EpochData {
new<T>(value: T) -> Result<Self, mls_rs_codec::Error> where T: MlsEncode + EpochRecord,34     pub(crate) fn new<T>(value: T) -> Result<Self, mls_rs_codec::Error>
35     where
36         T: MlsEncode + EpochRecord,
37     {
38         Ok(Self {
39             id: value.id(),
40             data: value.mls_encode_to_vec()?,
41         })
42     }
43 }
44