summaryrefslogtreecommitdiff
path: root/src/client/executor/tasks.rs
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-09-14 18:09:58 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-09-14 18:10:32 +0800
commitb0891c3ff11dd05c475a2b0f0e722b6b0e1aab5c (patch)
treee7cefa66e4b635e1dd508dd676087cff4fe1d044 /src/client/executor/tasks.rs
parent46cb6bcbe8ed6254aa06ff155828666d14ef7bed (diff)
chore: pub(crate) -> pub for same visibility
Diffstat (limited to 'src/client/executor/tasks.rs')
-rw-r--r--src/client/executor/tasks.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/client/executor/tasks.rs b/src/client/executor/tasks.rs
index 148e262..3d9d940 100644
--- a/src/client/executor/tasks.rs
+++ b/src/client/executor/tasks.rs
@@ -1,4 +1,4 @@
-pub(crate) struct Task {
+pub struct Task {
pub name: &'static str,
pub exec: fn(&[String]) -> Result<String, String>,
}
@@ -9,7 +9,7 @@ impl PartialEq for &Task {
}
}
-pub(crate) const TASKS: &[Task] = &[
+pub const TASKS: &[Task] = &[
Task {
name: "nop",
exec: no_op,
@@ -34,13 +34,9 @@ fn exec(cmds: &[String]) -> Result<String, String> {
match Command::new(cmds[0].as_str()).args(&cmds[1..]).output() {
Ok(o) => {
if o.status.success() {
- Ok(String::from_utf8(o.stdout)
- .unwrap_or("Failed decoding vec<u8> -> String".to_string())
- .to_string())
+ Ok(String::from_utf8_lossy(&o.stdout).to_string())
} else {
- Err(String::from_utf8(o.stderr)
- .unwrap_or("Failed decoding vec<u8> -> String".to_string())
- .to_string())
+ Err(String::from_utf8_lossy(&o.stderr).to_string())
}
}
Err(e) => Err(e.to_string()),
@@ -112,12 +108,10 @@ fn network(switch: &[String]) -> Result<String, String> {
).arg(if switch { "on" } else { "off" }).output() {
Ok(o) => {
if o.status.success() {
- Ok(String::from_utf8(o.stdout)
- .unwrap_or("Failed decoding vec<u8> -> String".to_string())
+ Ok(String::from_utf8_lossy(&o.stdout)
.to_string())
} else {
- Err(String::from_utf8(o.stderr)
- .unwrap_or("Failed decoding vec<u8> -> String".to_string())
+ Err(String::from_utf8_lossy(&o.stderr)
.to_string())
}
}
@@ -135,11 +129,11 @@ fn network(switch: &[String]) -> Result<String, String> {
}
#[derive(Debug)]
-pub(crate) enum IntoTaskErr {
+pub enum IntoTaskErr {
NotFound(String),
}
-pub(crate) trait IntoTask {
+pub trait IntoTask {
fn into_task<'a>(self) -> Result<&'a Task, IntoTaskErr>;
}