mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-16 14:47:25 +08:00
clippy all codes (#1214)
1. clippy code 2. add fmt and clippy check in ci
This commit is contained in:
@@ -18,6 +18,12 @@ pub struct NetworkInstanceManager {
|
||||
stop_check_notifier: Arc<tokio::sync::Notify>,
|
||||
}
|
||||
|
||||
impl Default for NetworkInstanceManager {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl NetworkInstanceManager {
|
||||
pub fn new() -> Self {
|
||||
NetworkInstanceManager {
|
||||
@@ -65,11 +71,9 @@ impl NetworkInstanceManager {
|
||||
let Some(instance_stop_notifier) = instance_stop_notifier else {
|
||||
return;
|
||||
};
|
||||
let _t = if let Some(event) = instance_event_receiver.flatten() {
|
||||
Some(ScopedTask::from(handle_event(instance_id, event)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let _t = instance_event_receiver
|
||||
.flatten()
|
||||
.map(|event| ScopedTask::from(handle_event(instance_id, event)));
|
||||
instance_stop_notifier.notified().await;
|
||||
if let Some(instance) = instance_map.get(&instance_id) {
|
||||
if let Some(e) = instance.get_latest_error_msg() {
|
||||
@@ -124,17 +128,14 @@ impl NetworkInstanceManager {
|
||||
let mut ret = BTreeMap::new();
|
||||
for instance in self.instance_map.iter() {
|
||||
if let Some(info) = instance.get_running_info() {
|
||||
ret.insert(instance.key().clone(), info);
|
||||
ret.insert(*instance.key(), info);
|
||||
}
|
||||
}
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
pub fn list_network_instance_ids(&self) -> Vec<uuid::Uuid> {
|
||||
self.instance_map
|
||||
.iter()
|
||||
.map(|item| item.key().clone())
|
||||
.collect()
|
||||
self.instance_map.iter().map(|item| *item.key()).collect()
|
||||
}
|
||||
|
||||
pub fn get_network_instance_name(&self, instance_id: &uuid::Uuid) -> Option<String> {
|
||||
@@ -299,8 +300,8 @@ fn handle_event(
|
||||
instance_id,
|
||||
format!(
|
||||
"port forward added. local: {}, remote: {}, proto: {}",
|
||||
cfg.bind_addr.unwrap().to_string(),
|
||||
cfg.dst_addr.unwrap().to_string(),
|
||||
cfg.bind_addr.unwrap(),
|
||||
cfg.dst_addr.unwrap(),
|
||||
cfg.socket_type().as_str_name()
|
||||
),
|
||||
);
|
||||
@@ -347,9 +348,8 @@ mod tests {
|
||||
let instance_id1 = manager
|
||||
.run_network_instance(
|
||||
TomlConfigLoader::new_from_str(cfg_str)
|
||||
.map(|c| {
|
||||
.inspect(|c| {
|
||||
c.set_listeners(vec![format!("tcp://0.0.0.0:{}", port).parse().unwrap()]);
|
||||
c
|
||||
})
|
||||
.unwrap(),
|
||||
ConfigSource::Cli,
|
||||
@@ -426,9 +426,8 @@ mod tests {
|
||||
assert!(manager
|
||||
.run_network_instance(
|
||||
TomlConfigLoader::new_from_str(cfg_str)
|
||||
.map(|c| {
|
||||
.inspect(|c| {
|
||||
c.set_listeners(vec![format!("tcp://0.0.0.0:{}", port).parse().unwrap()]);
|
||||
c
|
||||
})
|
||||
.unwrap(),
|
||||
ConfigSource::GUI,
|
||||
|
||||
Reference in New Issue
Block a user