use super::{CompressionLevel, CompressionType, EncryptionType};
#[derive(Clone, Debug)]
pub enum Handshake {
Client {
preferred_compression_type: Option<CompressionType>,
preferred_compression_level: Option<CompressionLevel>,
preferred_encryption_type: Option<EncryptionType>,
},
Server {
compression_types: Vec<CompressionType>,
encryption_types: Vec<EncryptionType>,
},
}
impl Handshake {
pub fn client() -> Self {
Self::Client {
preferred_compression_type: None,
preferred_compression_level: None,
preferred_encryption_type: Some(EncryptionType::XChaCha20Poly1305),
}
}
pub fn server() -> Self {
Self::Server {
compression_types: CompressionType::known_variants().to_vec(),
encryption_types: EncryptionType::known_variants().to_vec(),
}
}
pub fn is_client(&self) -> bool {
matches!(self, Self::Client { .. })
}
pub fn is_server(&self) -> bool {
matches!(self, Self::Server { .. })
}
}