#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct WireGuardMessage {
pub kind: WireGuardKind,
pub sender_index: Option<u32>,
pub receiver_index: Option<u32>,
pub payload_length: Option<u32>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
#[non_exhaustive]
pub enum WireGuardKind {
HandshakeInitiation,
HandshakeResponse,
CookieReply,
TransportData,
}
impl WireGuardKind {
pub fn as_str(&self) -> &'static str {
match self {
Self::HandshakeInitiation => "handshake_initiation",
Self::HandshakeResponse => "handshake_response",
Self::CookieReply => "cookie_reply",
Self::TransportData => "transport_data",
}
}
pub fn is_handshake(&self) -> bool {
matches!(self, Self::HandshakeInitiation | Self::HandshakeResponse)
}
}