lints
This commit is contained in:
@@ -44,7 +44,7 @@ struct RegistrationImpl {
|
||||
impl RegistrationImpl {
|
||||
fn new(id: u64, registrations: Rc<RefCell<RegistrationMap>>) -> Self {
|
||||
Self {
|
||||
id: id,
|
||||
id,
|
||||
registration_map: registrations,
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ impl VeilidServerImpl {
|
||||
Self {
|
||||
next_id: 0,
|
||||
registration_map: Rc::new(RefCell::new(RegistrationMap::new())),
|
||||
veilid_api: veilid_api,
|
||||
veilid_api,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ impl ClientApi {
|
||||
pub fn new(veilid_api: veilid_core::VeilidAPI) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
inner: RefCell::new(ClientApiInner {
|
||||
veilid_api: veilid_api,
|
||||
veilid_api,
|
||||
registration_map: Rc::new(RefCell::new(RegistrationMap::new())),
|
||||
stop: Eventual::new(),
|
||||
join_handle: None,
|
||||
@@ -283,13 +283,10 @@ impl ClientApi {
|
||||
let registration_map2 = registration_map1.clone();
|
||||
async_std::task::spawn_local(request.send().promise.map(move |r| match r {
|
||||
Ok(_) => {
|
||||
registration_map2
|
||||
if let Some(ref mut s) = registration_map2
|
||||
.borrow_mut()
|
||||
.registrations
|
||||
.get_mut(&id)
|
||||
.map(|ref mut s| {
|
||||
s.requests_in_flight -= 1;
|
||||
});
|
||||
.get_mut(&id) { s.requests_in_flight -= 1; }
|
||||
}
|
||||
Err(e) => {
|
||||
debug!("Got error: {:?}. Dropping registation.", e);
|
||||
@@ -309,7 +306,7 @@ impl ClientApi {
|
||||
|
||||
let bind_futures = bind_addrs
|
||||
.iter()
|
||||
.map(|addr| self.clone().handle_incoming(addr.clone(), client.clone()));
|
||||
.map(|addr| self.clone().handle_incoming(*addr, client.clone()));
|
||||
let bind_futures_join = futures::future::try_join_all(bind_futures);
|
||||
self.inner.borrow_mut().join_handle = Some(async_std::task::spawn_local(bind_futures_join));
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ pub mod veilid_client_capnp {
|
||||
include!(concat!(env!("OUT_DIR"), "/proto/veilid_client_capnp.rs"));
|
||||
}
|
||||
|
||||
use cfg_if;
|
||||
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(windows)] {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use config;
|
||||
|
||||
use directories::*;
|
||||
use log::*;
|
||||
use parking_lot::*;
|
||||
use serde;
|
||||
|
||||
use serde_derive::*;
|
||||
use std::ffi::OsStr;
|
||||
use std::net::{SocketAddr, ToSocketAddrs};
|
||||
@@ -184,7 +184,7 @@ impl FromStr for ParsedURL {
|
||||
|
||||
Ok(Self {
|
||||
urlstring: s.to_string(),
|
||||
url: url,
|
||||
url,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ impl<'de> serde::Deserialize<'de> for ParsedURL {
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
Ok(ParsedURL::from_str(s.as_str()).map_err(|x| serde::de::Error::custom(x))?)
|
||||
ParsedURL::from_str(s.as_str()).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ impl<'de> serde::Deserialize<'de> for NamedSocketAddrs {
|
||||
D: serde::Deserializer<'de>,
|
||||
{
|
||||
let s = String::deserialize(deserializer)?;
|
||||
Ok(NamedSocketAddrs::from_str(s.as_str()).map_err(|x| serde::de::Error::custom(x))?)
|
||||
NamedSocketAddrs::from_str(s.as_str()).map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,11 +709,7 @@ impl Settings {
|
||||
inner.core.network.protocol.udp.listen_address.name.clone(),
|
||||
)),
|
||||
"network.protocol.udp.public_address" => Ok(Box::new(
|
||||
if let Some(a) = &inner.core.network.protocol.udp.public_address {
|
||||
Some(a.name.clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
inner.core.network.protocol.udp.public_address.as_ref().map(|a| a.name.clone()),
|
||||
)),
|
||||
"network.protocol.tcp.connect" => {
|
||||
Ok(Box::new(inner.core.network.protocol.tcp.connect))
|
||||
@@ -728,11 +724,7 @@ impl Settings {
|
||||
inner.core.network.protocol.tcp.listen_address.name.clone(),
|
||||
)),
|
||||
"network.protocol.tcp.public_address" => Ok(Box::new(
|
||||
if let Some(a) = &inner.core.network.protocol.tcp.public_address {
|
||||
Some(a.name.clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
inner.core.network.protocol.tcp.public_address.as_ref().map(|a| a.name.clone()),
|
||||
)),
|
||||
"network.protocol.ws.connect" => {
|
||||
Ok(Box::new(inner.core.network.protocol.ws.connect))
|
||||
@@ -748,11 +740,7 @@ impl Settings {
|
||||
Ok(Box::new(inner.core.network.protocol.ws.path.clone()))
|
||||
}
|
||||
"network.protocol.ws.public_address" => Ok(Box::new(
|
||||
if let Some(a) = &inner.core.network.protocol.ws.public_address {
|
||||
Some(a.name.clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
inner.core.network.protocol.ws.public_address.as_ref().map(|a| a.name.clone()),
|
||||
)),
|
||||
"network.protocol.wss.connect" => {
|
||||
Ok(Box::new(inner.core.network.protocol.wss.connect))
|
||||
@@ -770,11 +758,7 @@ impl Settings {
|
||||
Ok(Box::new(inner.core.network.protocol.wss.path.clone()))
|
||||
}
|
||||
"network.protocol.wss.public_address" => Ok(Box::new(
|
||||
if let Some(a) = &inner.core.network.protocol.wss.public_address {
|
||||
Some(a.name.clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
inner.core.network.protocol.wss.public_address.as_ref().map(|a| a.name.clone()),
|
||||
)),
|
||||
"network.leases.max_server_signal_leases" => {
|
||||
Ok(Box::new(inner.core.network.leases.max_server_signal_leases))
|
||||
@@ -845,7 +829,7 @@ mod tests {
|
||||
veilid_core::DHTKeySecret::default()
|
||||
);
|
||||
//
|
||||
assert!(s.core.network.bootstrap.len() == 0);
|
||||
assert!(s.core.network.bootstrap.is_empty());
|
||||
//
|
||||
assert_eq!(s.core.network.rpc.concurrency, 0);
|
||||
assert_eq!(s.core.network.rpc.queue_size, 1024);
|
||||
|
@@ -168,7 +168,7 @@ pub async fn main() -> Result<(), String> {
|
||||
Some(x) => {
|
||||
println!("Overriding bootstrap with: ");
|
||||
let mut out: Vec<settings::ParsedURL> = Vec::new();
|
||||
for x in x.split(",") {
|
||||
for x in x.split(',') {
|
||||
println!(" {}", x);
|
||||
out.push(
|
||||
settings::ParsedURL::from_str(x)
|
||||
@@ -251,7 +251,7 @@ pub async fn main() -> Result<(), String> {
|
||||
move |change: veilid_core::VeilidStateChange| -> veilid_core::SystemPinBoxFuture<()> {
|
||||
let sender = sender.clone();
|
||||
Box::pin(async move {
|
||||
if let Err(_) = sender.send(change).await {
|
||||
if sender.send(change).await.is_err() {
|
||||
error!("error sending state change callback");
|
||||
}
|
||||
})
|
||||
@@ -308,11 +308,7 @@ pub async fn main() -> Result<(), String> {
|
||||
// Idle while waiting to exit
|
||||
let shutdown_switch = {
|
||||
let shutdown_switch_locked = SHUTDOWN_SWITCH.lock();
|
||||
if let Some(ss) = &*shutdown_switch_locked {
|
||||
Some(ss.instance())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
(*shutdown_switch_locked).as_ref().map(|ss| ss.instance())
|
||||
};
|
||||
if let Some(shutdown_switch) = shutdown_switch {
|
||||
shutdown_switch.await;
|
||||
|
Reference in New Issue
Block a user