diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-09-19 17:47:46 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-09-19 17:47:46 +0800 |
| commit | ba808044be8f3123736d10f14478a07fe020c9b7 (patch) | |
| tree | d804d21adaf5c5ff877f8a5ffcdaa475da1a692f /src | |
| parent | dfddb8995ad68f9591a1e3e7c380d944a4f3b9d2 (diff) | |
chore: more concise qualification
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/connector.rs | 8 | ||||
| -rw-r--r-- | src/client/connector/httpconnector.rs | 4 | ||||
| -rw-r--r-- | src/tasks.rs | 4 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/client/connector.rs b/src/client/connector.rs index ee40089..f9cee1a 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -1,11 +1,15 @@ pub mod httpconnector; -use std::net::IpAddr; +use std::{ + fmt::{Debug, Display}, + net::IpAddr, + result, +}; use crate::{client::Client, executor::Executor}; use remote_control_rs::tasks::NETWORK_T; -pub type Result<T: std::fmt::Display, E: std::fmt::Debug> = std::result::Result<T, E>; +pub type Result<T: Display, E: Debug> = result::Result<T, E>; pub trait Connection { type Ok: std::fmt::Display + AsRef<str> = String; diff --git a/src/client/connector/httpconnector.rs b/src/client/connector/httpconnector.rs index 5cfbe30..dbd094c 100644 --- a/src/client/connector/httpconnector.rs +++ b/src/client/connector/httpconnector.rs @@ -4,7 +4,7 @@ use reqwest::{ Error, StatusCode, Url, blocking::{Client, RequestBuilder}, }; -use std::{net::IpAddr, thread::sleep, time::Duration}; +use std::{net::IpAddr, result, thread::sleep, time::Duration}; #[derive(Debug)] pub enum HTTPConnectorError { @@ -34,7 +34,7 @@ pub struct HTTPConnector { } impl HTTPConnector { - pub fn new(pull_url: &str, ntfy_url: &str, ip_getter_url: &str) -> std::result::Result<Self, HTTPConnectorError> { + pub fn new(pull_url: &str, ntfy_url: &str, ip_getter_url: &str) -> result::Result<Self, HTTPConnectorError> { Ok(Self { network_enforcer: Executor::new(&NETWORK_T, ["true"]).unwrap(), // .unwrap() should never panic prev: String::new(), diff --git a/src/tasks.rs b/src/tasks.rs index e862f79..0e196b2 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + pub struct Task { pub name: Name, pub exec: fn(&[&str]) -> Result<String, String>, @@ -10,7 +12,7 @@ pub enum Name { Network, } -impl std::fmt::Display for Name { +impl Display for Name { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{:?}", self) } |
