use core::{fmt, ops::Deref};
pub use capabilities::{Bandwidth, Capabilities};
pub use datagram_flags::DatagramFlags;
pub use date::Date;
pub use destination::{Destination, DestinationId};
pub use lease_set::{Lease, LeaseSet2, LeaseSet2Header};
pub use mapping::Mapping;
pub use offline_signature::OfflineSignature;
pub use router_address::{MlKemPreference, RouterAddress, TransportKind};
pub use router_identity::{RouterId, RouterIdentity};
pub use router_info::RouterInfo;
pub use string::Str;
#[cfg(test)]
pub use router_info::builder::RouterInfoBuilder;
#[cfg(test)]
use crate::runtime::Runtime;
mod capabilities;
mod datagram_flags;
mod date;
mod destination;
mod lease_set;
mod mapping;
mod offline_signature;
mod router_address;
mod router_identity;
mod router_info;
mod string;
const LOG_TARGET: &str = "emissary::primitives";
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
pub struct TunnelId(u32);
impl TunnelId {
#[cfg(test)]
pub fn random() -> TunnelId {
use crate::runtime::mock::MockRuntime;
use rand::Rng;
TunnelId::from(MockRuntime::rng().next_u32())
}
}
impl From<u32> for TunnelId {
fn from(value: u32) -> Self {
TunnelId(value)
}
}
impl From<TunnelId> for u32 {
fn from(value: TunnelId) -> Self {
value.0
}
}
impl Deref for TunnelId {
type Target = u32;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl fmt::Display for TunnelId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct MessageId(u32);
impl MessageId {
#[cfg(test)]
pub fn random() -> MessageId {
use crate::runtime::mock::MockRuntime;
use rand::Rng;
MessageId::from(MockRuntime::rng().next_u32())
}
}
impl From<u32> for MessageId {
fn from(value: u32) -> Self {
MessageId(value)
}
}
impl From<MessageId> for u32 {
fn from(value: MessageId) -> Self {
value.0
}
}
impl fmt::Display for MessageId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl Deref for MessageId {
type Target = u32;
fn deref(&self) -> &Self::Target {
&self.0
}
}