pub type ConversationId = u64;
pub type ParticipantId = u64;
pub type ParticipantIndex = u64;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Generation(core::num::NonZeroU64);
impl Generation {
pub const ONE: Self = Self(core::num::NonZeroU64::MIN);
#[must_use]
pub const fn new(value: u64) -> Option<Self> {
match core::num::NonZeroU64::new(value) {
Some(value) => Some(Self(value)),
None => None,
}
}
#[must_use]
pub const fn get(self) -> u64 {
self.0.get()
}
}
pub type DeliverySeq = u64;
pub type TransactionOrder = u64;
pub type ObserverEpoch = u64;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct ProtocolVersion {
pub major: u16,
pub minor: u16,
}
impl ProtocolVersion {
pub const V1: Self = Self { major: 1, minor: 0 };
#[must_use]
pub const fn new(major: u16, minor: u16) -> Self {
Self { major, minor }
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ConnectionIncarnation {
pub server_incarnation: u64,
pub connection_ordinal: u64,
}
impl ConnectionIncarnation {
#[must_use]
pub const fn new(server_incarnation: u64, connection_ordinal: u64) -> Self {
Self {
server_incarnation,
connection_ordinal,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BindingEpoch {
pub connection_incarnation: ConnectionIncarnation,
pub capability_generation: Generation,
}
impl BindingEpoch {
#[must_use]
pub const fn new(
connection_incarnation: ConnectionIncarnation,
capability_generation: Generation,
) -> Self {
Self {
connection_incarnation,
capability_generation,
}
}
}
macro_rules! fixed_credential {
($(#[$meta:meta])* $name:ident, $length:expr) => {
$(#[$meta])*
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct $name([u8; $length]);
impl $name {
#[must_use]
pub const fn new(bytes: [u8; $length]) -> Self {
Self(bytes)
}
#[must_use]
pub const fn into_bytes(self) -> [u8; $length] {
self.0
}
#[must_use]
pub const fn as_bytes(&self) -> &[u8; $length] {
&self.0
}
}
};
}
fixed_credential!(
EnrollmentToken,
16
);
fixed_credential!(
AttachAttemptToken,
16
);
fixed_credential!(
DetachAttemptToken,
16
);
fixed_credential!(
LeaveAttemptToken,
16
);
fixed_credential!(
RecordAdmissionAttemptToken,
16
);
fixed_credential!(
AttachSecret,
32
);