diff --git a/veilid-cli/src/command_processor.rs b/veilid-cli/src/command_processor.rs index deeea36e..6897971e 100644 --- a/veilid-cli/src/command_processor.rs +++ b/veilid-cli/src/command_processor.rs @@ -18,22 +18,13 @@ pub enum ConnectionState { } impl ConnectionState { pub fn is_disconnected(&self) -> bool { - match *self { - Self::Disconnected => true, - _ => false, - } + matches!(*self, Self::Disconnected) } pub fn is_connected(&self) -> bool { - match *self { - Self::Connected(_, _) => true, - _ => false, - } + matches!(*self, Self::Connected(_, _)) } pub fn is_retrying(&self) -> bool { - match *self { - Self::Retrying(_, _) => true, - _ => false, - } + matches!(*self, Self::Retrying(_, _)) } } diff --git a/veilid-cli/src/main.rs b/veilid-cli/src/main.rs index aac2f834..fa57c1b7 100644 --- a/veilid-cli/src/main.rs +++ b/veilid-cli/src/main.rs @@ -13,13 +13,12 @@ mod command_processor; mod settings; mod ui; +#[allow(clippy::all)] pub mod veilid_client_capnp { include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs")); } -fn parse_command_line<'a>( - default_config_path: &'a OsStr, -) -> Result, clap::Error> { +fn parse_command_line(default_config_path: &OsStr) -> Result { let matches = App::new("veilid-cli") .version("0.1") .about("Veilid Console Client") diff --git a/veilid-server/src/client_api.rs b/veilid-server/src/client_api.rs index 467f6595..134712e6 100644 --- a/veilid-server/src/client_api.rs +++ b/veilid-server/src/client_api.rs @@ -158,13 +158,14 @@ impl veilid_server::Server for VeilidServerImpl { // --- Client API Server-Side --------------------------------- +type ClientApiAllFuturesJoinHandle = + async_std::task::JoinHandle, Box<(dyn std::error::Error + 'static)>>>; + struct ClientApiInner { veilid_api: veilid_core::VeilidAPI, registration_map: Rc>, stop: Eventual, - join_handle: Option< - async_std::task::JoinHandle, Box<(dyn std::error::Error + 'static)>>>, - >, + join_handle: Option, } pub struct ClientApi { @@ -283,10 +284,11 @@ impl ClientApi { let registration_map2 = registration_map1.clone(); async_std::task::spawn_local(request.send().promise.map(move |r| match r { Ok(_) => { - if let Some(ref mut s) = registration_map2 - .borrow_mut() - .registrations - .get_mut(&id) { s.requests_in_flight -= 1; } + if let Some(ref mut s) = + registration_map2.borrow_mut().registrations.get_mut(&id) + { + s.requests_in_flight -= 1; + } } Err(e) => { debug!("Got error: {:?}. Dropping registation.", e); diff --git a/veilid-server/src/main.rs b/veilid-server/src/main.rs index abcbc030..4aeae6f9 100644 --- a/veilid-server/src/main.rs +++ b/veilid-server/src/main.rs @@ -4,6 +4,7 @@ mod client_api; mod settings; +#[allow(clippy::all)] pub mod veilid_client_capnp { include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs")); } diff --git a/veilid-server/src/settings.rs b/veilid-server/src/settings.rs index fa370860..06250410 100644 --- a/veilid-server/src/settings.rs +++ b/veilid-server/src/settings.rs @@ -276,13 +276,13 @@ pub struct Logging { } #[derive(Debug, Deserialize)] -pub struct HTTPS { +pub struct Https { pub enabled: bool, pub listen_address: NamedSocketAddrs, } #[derive(Debug, Deserialize)] -pub struct HTTP { +pub struct Http { pub enabled: bool, pub listen_address: NamedSocketAddrs, } @@ -290,12 +290,12 @@ pub struct HTTP { #[derive(Debug, Deserialize)] pub struct Application { pub path: PathBuf, - pub https: HTTPS, - pub http: HTTP, + pub https: Https, + pub http: Http, } #[derive(Debug, Deserialize)] -pub struct UDP { +pub struct Udp { pub enabled: bool, pub socket_pool_size: u32, pub listen_address: NamedSocketAddrs, @@ -303,7 +303,7 @@ pub struct UDP { } #[derive(Debug, Deserialize)] -pub struct TCP { +pub struct Tcp { pub connect: bool, pub listen: bool, pub max_connections: u32, @@ -312,7 +312,7 @@ pub struct TCP { } #[derive(Debug, Deserialize)] -pub struct WS { +pub struct Ws { pub connect: bool, pub listen: bool, pub max_connections: u32, @@ -322,7 +322,7 @@ pub struct WS { } #[derive(Debug, Deserialize)] -pub struct WSS { +pub struct Wss { pub connect: bool, pub listen: bool, pub max_connections: u32, @@ -333,21 +333,21 @@ pub struct WSS { #[derive(Debug, Deserialize)] pub struct Protocol { - pub udp: UDP, - pub tcp: TCP, - pub ws: WS, - pub wss: WSS, + pub udp: Udp, + pub tcp: Tcp, + pub ws: Ws, + pub wss: Wss, } #[derive(Debug, Deserialize)] -pub struct TLS { +pub struct Tls { pub certificate_path: PathBuf, pub private_key_path: PathBuf, pub connection_initial_timeout: u64, } #[derive(Debug, Deserialize)] -pub struct RPC { +pub struct Rpc { pub concurrency: u32, pub queue_size: u32, pub max_timestamp_behind: Option, @@ -357,7 +357,7 @@ pub struct RPC { } #[derive(Debug, Deserialize)] -pub struct DHT { +pub struct Dht { pub resolve_node_timeout: Option, pub resolve_node_count: u32, pub resolve_node_fanout: u32, @@ -388,13 +388,13 @@ pub struct Network { pub node_id: veilid_core::DHTKey, pub node_id_secret: veilid_core::DHTKeySecret, pub bootstrap: Vec, - pub rpc: RPC, - pub dht: DHT, + pub rpc: Rpc, + pub dht: Dht, pub upnp: bool, pub natpmp: bool, pub address_filter: bool, pub restricted_nat_retries: u32, - pub tls: TLS, + pub tls: Tls, pub application: Application, pub protocol: Protocol, pub leases: Leases, diff --git a/veilid-server/src/unix.rs b/veilid-server/src/unix.rs index 2fa6f630..f8396f84 100644 --- a/veilid-server/src/unix.rs +++ b/veilid-server/src/unix.rs @@ -16,9 +16,7 @@ use std::str::FromStr; use std::sync::Arc; use veilid_core::xx::SingleShotEventual; -fn parse_command_line<'a>( - default_config_path: &'a OsStr, -) -> Result, clap::Error> { +fn parse_command_line(default_config_path: &OsStr) -> Result { let matches = App::new("veilid-server") .version("0.1") .about("Veilid Server") @@ -158,10 +156,7 @@ pub async fn main() -> Result<(), String> { settingsrw.logging.file.level = settings::LogLevel::Trace; } if matches.is_present("attach") { - settingsrw.auto_attach = match matches.value_of("attach") { - Some("false") => false, - _ => true, - }; + settingsrw.auto_attach = !matches!(matches.value_of("attach"), Some("false")); } if matches.occurrences_of("bootstrap") != 0 { let bootstrap = match matches.value_of("bootstrap") { @@ -284,18 +279,10 @@ pub async fn main() -> Result<(), String> { // Handle state changes on main thread for capnproto rpc let capi2 = capi.clone(); let capi_jh = async_std::task::spawn_local(async move { - loop { - let change = match receiver.recv().await { - Ok(change) => change, - Err(_) => { - break; - } - }; - let c = match capi2.borrow_mut().as_mut() { - Some(some_capi) => some_capi.clone(), - None => continue, - }; - c.handle_state_change(change); + while let Ok(change) = receiver.recv().await { + if let Some(c) = capi2.borrow_mut().as_mut().cloned() { + c.handle_state_change(change); + } } }); @@ -315,11 +302,8 @@ pub async fn main() -> Result<(), String> { } // Stop the client api if we have one - match capi.borrow_mut().as_mut().cloned() { - Some(some_capi) => { - some_capi.stop().await; - } - None => (), + if let Some(c) = capi.borrow_mut().as_mut().cloned() { + c.stop().await; } // Shut down Veilid API