summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-09-18 18:45:36 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-09-18 18:48:42 +0800
commitd089c1611b94c6c19d2998a56d9f4d2a983f9833 (patch)
tree862d3953653a4c878bfd9a43551346ea90ab04c7
parent0798c029cee16875fb09ea6a158dbab2dcf13aab (diff)
client: move inner info to seperate file
-rw-r--r--src/client.rs16
-rw-r--r--src/client/client.rs45
-rw-r--r--src/lib.rs1
3 files changed, 35 insertions, 27 deletions
diff --git a/src/client.rs b/src/client.rs
new file mode 100644
index 0000000..2377549
--- /dev/null
+++ b/src/client.rs
@@ -0,0 +1,16 @@
+use std::net::IpAddr;
+use whoami::{DesktopEnv, Language};
+
+pub struct Client<'a> {
+ pub ip: Option<IpAddr>,
+ pub hostname: String,
+ pub device_name: String,
+ pub os: &'a str,
+ pub cpu_arch: &'a str,
+ pub distro: String,
+ pub desktop_env: DesktopEnv,
+ pub username: String,
+ pub realname: String,
+ pub langs: Option<Vec<Language>>,
+ pub env: Vec<(String, String)>,
+}
diff --git a/src/client/client.rs b/src/client/client.rs
index 73a2c30..5293063 100644
--- a/src/client/client.rs
+++ b/src/client/client.rs
@@ -6,18 +6,7 @@ use crate::connector::Connection;
pub struct Client<'a, C: Connection> {
pub connector: C,
-
- ip: Option<IpAddr>,
- hostname: String,
- device_name: String,
- os: &'a str,
- cpu_arch: &'a str,
- distro: String,
- desktop_env: DesktopEnv,
- username: String,
- realname: String,
- langs: Option<Vec<Language>>,
- env: Vec<(String, String)>,
+ inner: remote_control_rs::client::Client<'a>,
}
impl<'a, C: Connection> std::fmt::Display for Client<'a, C> {
@@ -35,7 +24,7 @@ impl<'a, C: Connection> std::fmt::Display for Client<'a, C> {
Real Name: {}\n\
Languages: {:?}\n\
Environment Variables: {:?}\n",
- self.ip, self.hostname, self.device_name, self.os, self.cpu_arch, self.distro, self.desktop_env, self.username, self.realname, self.langs, self.env
+ self.inner.ip, self.inner.hostname, self.inner.device_name, self.inner.os, self.inner.cpu_arch, self.inner.distro, self.inner.desktop_env, self.inner.username, self.inner.realname, self.inner.langs, self.inner.env
)
}
}
@@ -43,21 +32,23 @@ impl<'a, C: Connection> std::fmt::Display for Client<'a, C> {
impl<'a, C: Connection> Client<'a, C> {
pub fn new(connector: C) -> Result<Self, C::Err> {
let c = Self {
- ip: connector.get_ip(),
- connector,
- hostname: gethostname().into_string().unwrap_or_default(),
- device_name: whoami::devicename(),
- os: std::env::consts::OS,
- cpu_arch: std::env::consts::ARCH,
- distro: whoami::distro(),
- desktop_env: whoami::desktop_env(),
- username: whoami::username(),
- realname: whoami::realname(),
- langs: match whoami::langs() {
- Ok(it) => Some(it.collect()),
- Err(_) => None,
+ inner: remote_control_rs::client::Client {
+ ip: connector.get_ip(),
+ hostname: gethostname().into_string().unwrap_or_default(),
+ device_name: whoami::devicename(),
+ os: std::env::consts::OS,
+ cpu_arch: std::env::consts::ARCH,
+ distro: whoami::distro(),
+ desktop_env: whoami::desktop_env(),
+ username: whoami::username(),
+ realname: whoami::realname(),
+ langs: match whoami::langs() {
+ Ok(it) => Some(it.collect()),
+ Err(_) => None,
+ },
+ env: std::env::vars().collect(),
},
- env: std::env::vars().collect(),
+ connector,
};
c.connector.init(&c)?;
Ok(c)
diff --git a/src/lib.rs b/src/lib.rs
index 16e25a6..c97d0c4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,2 +1,3 @@
#![allow(clippy::redundant_field_names)]
+pub mod client;
pub mod tasks;