//! Configuration use super::*; use sock::SocketAddr; pub const DEFAULT_BUFFER_SIZE: usize = 4096; /// What kind of compression to use #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Copy)] #[repr(u8)] pub enum CompressionKind { Brotli, GZip, BZ2, } // -- serve / conn -- /// Server configuration #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ServerConfig { pub bind: SocketAddr, pub oneshot: bool, } /// Client configuration #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ClientConfig { pub connect: SocketAddr, pub retry: usize, } // -- send / recv --- /// Specifying a sending name, or send the filename #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SendingName { Filename, Specific(String), } impl Default for SendingName { #[inline] fn default() -> Self { Self::Filename } } /// Configuration for sending file #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SendConfig { pub encrypt: bool, pub sign: bool, pub compress: Option, pub buffer_size: usize, pub continuation: bool, pub name: Option, } /// Configuration for receiving file #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RecvConfig { pub interactive: bool, pub name: SendingName, } // -- modes -- /// Mode of file #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum TransferMode { Send(SendConfig), Recv(RecvConfig), } /// Configuration of connection #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ConnectionMode { Server(ServerConfig), Client(ClientConfig), } // -- /// Full program configuration /// /// You should box this, it's big. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Config { pub file: TransferMode, pub connection: ConnectionMode, }