mls_rs_core/
protocol_version.rsuse core::ops::Deref;
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};
#[derive(
Debug, Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd, MlsSize, MlsEncode, MlsDecode,
)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[cfg_attr(all(feature = "ffi", not(test)), safer_ffi_gen::ffi_type)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[repr(transparent)]
pub struct ProtocolVersion(u16);
impl From<u16> for ProtocolVersion {
fn from(value: u16) -> Self {
ProtocolVersion(value)
}
}
impl From<ProtocolVersion> for u16 {
fn from(value: ProtocolVersion) -> Self {
value.0
}
}
impl Deref for ProtocolVersion {
type Target = u16;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl ProtocolVersion {
pub const MLS_10: ProtocolVersion = ProtocolVersion(1);
pub const fn new(value: u16) -> ProtocolVersion {
ProtocolVersion(value)
}
pub const fn raw_value(&self) -> u16 {
self.0
}
pub fn all() -> impl Iterator<Item = ProtocolVersion> {
[Self::MLS_10].into_iter()
}
}