diff --git a/src/boot_model/unit_facts.rs b/src/boot_model/unit_facts.rs index 68df69c..c0bc2c0 100644 --- a/src/boot_model/unit_facts.rs +++ b/src/boot_model/unit_facts.rs @@ -10,20 +10,6 @@ pub enum ActiveState { Failed, } -impl ActiveState { - #[must_use] - pub fn parse(raw: &str) -> Self { - match raw { - "activating" => Self::Activating, - "active" => Self::Active, - "deactivating" => Self::Deactivating, - "reloading" => Self::Reloading, - "failed" => Self::Failed, - _ => Self::Inactive, - } - } -} - #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum JobResult { Done, @@ -34,20 +20,6 @@ pub enum JobResult { Dependency, } -impl JobResult { - #[must_use] - pub fn parse(raw: &str) -> Self { - match raw { - "done" => Self::Done, - "skipped" => Self::Skipped, - "canceled" => Self::Canceled, - "timeout" => Self::Timeout, - "dependency" => Self::Dependency, - _ => Self::Failed, - } - } -} - #[derive(Clone, Debug, PartialEq, Eq)] pub struct UnitFacts { pub name: String, diff --git a/src/systemd_link/systemd_bus.rs b/src/systemd_link/systemd_bus.rs index d9210c6..6c602b4 100644 --- a/src/systemd_link/systemd_bus.rs +++ b/src/systemd_link/systemd_bus.rs @@ -298,7 +298,7 @@ fn parse_job_signal(message: &Message, member: &str) -> Option { message.read4().ok()?; Some(Signal::JobRemoved { id, - result: JobResult::parse(&result), + result: job_result_from_bus(&result), }) } _ => None, @@ -329,9 +329,31 @@ fn activity_from(properties: &PropMap) -> Activity { state: properties .get("ActiveState") .and_then(|value| value.0.as_str()) - .map(ActiveState::parse), + .map(active_state_from_bus), inactive_exit: monotonic("InactiveExitTimestampMonotonic"), active_enter: monotonic("ActiveEnterTimestampMonotonic"), active_exit: monotonic("ActiveExitTimestampMonotonic"), } } + +fn active_state_from_bus(raw: &str) -> ActiveState { + match raw { + "activating" => ActiveState::Activating, + "active" => ActiveState::Active, + "deactivating" => ActiveState::Deactivating, + "reloading" => ActiveState::Reloading, + "failed" => ActiveState::Failed, + _ => ActiveState::Inactive, + } +} + +fn job_result_from_bus(raw: &str) -> JobResult { + match raw { + "done" => JobResult::Done, + "skipped" => JobResult::Skipped, + "canceled" => JobResult::Canceled, + "timeout" => JobResult::Timeout, + "dependency" => JobResult::Dependency, + _ => JobResult::Failed, + } +}