use ts_keys::DerpServerPublicKey;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, Unaligned};
use crate::{
frame,
frame::{Body, FrameType},
};
#[derive(
Debug, Copy, Clone, PartialEq, KnownLayout, Immutable, IntoBytes, FromBytes, Unaligned,
)]
#[repr(C, packed)]
pub struct ServerKey {
pub magic: frame::Magic,
pub key: DerpServerPublicKey,
}
impl ServerKey {
pub fn validate(&self) -> Result<(), frame::Error> {
if !self.magic.is_valid() {
return Err(frame::Error::InvalidMagic);
}
Ok(())
}
}
impl Body for ServerKey {
const FRAME_TYPE: FrameType = FrameType::ServerKey;
}