mod group_context;
use crate::ciphersuite::*;
use crate::extensions::*;
use crate::utils::*;
use openmls_traits::OpenMlsCryptoProvider;
use serde::{Deserialize, Serialize};
use tls_codec::*;
pub(crate) mod core_group;
pub(crate) use core_group::*;
pub(crate) mod mls_group;
#[cfg(not(any(feature = "test-utils", test)))]
pub(crate) use group_context::*;
pub mod errors;
pub use core_group::proposals::*;
pub use core_group::staged_commit::StagedCommit;
pub use mls_group::config::*;
pub use mls_group::membership::*;
pub use mls_group::processing::*;
pub use mls_group::*;
#[cfg(any(feature = "test-utils", test))]
pub(crate) use create_commit_params::*;
#[cfg(any(feature = "test-utils", test))]
pub(crate) mod tests;
#[cfg(any(feature = "test-utils", test))]
pub use group_context::GroupContext;
#[cfg(any(feature = "test-utils", test))]
use openmls_traits::random::OpenMlsRand;
#[cfg(any(feature = "test-utils", test))]
pub use proposals::*;
#[derive(
Hash, Eq, Debug, PartialEq, Clone, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize,
)]
pub struct GroupId {
value: TlsByteVecU8,
}
impl GroupId {
#[cfg(any(feature = "test-utils", test))]
pub fn random(rng: &impl OpenMlsCryptoProvider) -> Self {
Self {
value: rng
.rand()
.random_vec(16)
.expect("Not enough randomness.")
.into(),
}
}
pub fn from_slice(bytes: &[u8]) -> Self {
GroupId {
value: bytes.into(),
}
}
pub fn as_slice(&self) -> &[u8] {
self.value.as_slice()
}
pub fn to_vec(&self) -> Vec<u8> {
self.value.clone().into()
}
}
#[derive(
Debug,
PartialEq,
Copy,
Clone,
Hash,
Serialize,
Deserialize,
TlsDeserialize,
TlsSerialize,
TlsSize,
)]
pub struct GroupEpoch(u64);
impl GroupEpoch {
pub(crate) fn increment(&mut self) {
self.0 += 1;
}
pub fn as_u64(&self) -> u64 {
self.0
}
}
impl PartialOrd for GroupEpoch {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.partial_cmp(&other.0)
}
}
impl From<u64> for GroupEpoch {
fn from(val: u64) -> Self {
Self(val)
}
}