sysd-manager 2.19.4

Application to empower user to manage their <b>systemd units</b> via Graphical User Interface. Not only are you able to make changes to the enablement and running status of each of the units, but you will also be able to view and modify their unit files and check the journal logs.
use gettextrs::pgettext;
use systemd::enums::ActiveState;

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum UnitContolType {
    Start,
    Stop,
    Restart,
    Reload,
}

impl UnitContolType {
    pub fn code(&self) -> &str {
        match self {
            UnitContolType::Start => "start",
            UnitContolType::Stop => "stop",
            UnitContolType::Restart => "restart",
            UnitContolType::Reload => "reload_unit",
        }
    }
    pub fn label(&self) -> String {
        match self {
            //unit action in toast message
            UnitContolType::Start => pgettext("toast", "start"),
            //unit action in toast message
            UnitContolType::Stop => pgettext("toast", "stop"),
            //unit action in toast message
            UnitContolType::Restart => pgettext("toast", "restart"),
            //unit action in toast message
            UnitContolType::Reload => pgettext("toast", "reload"),
        }
    }

    pub fn past_participle(&self) -> String {
        match self {
            //unit action in toast message
            UnitContolType::Start => pgettext("toast", "started"),
            //unit action in toast message
            UnitContolType::Stop => pgettext("toast", "stopped"),
            //unit action in toast message
            UnitContolType::Restart => pgettext("toast", "restarted"),
            //unit action in toast message
            UnitContolType::Reload => pgettext("toast", "reloaded"),
        }
    }

    pub fn on_succes_unit_state(&self) -> ActiveState {
        match self {
            UnitContolType::Start => ActiveState::Active,
            UnitContolType::Stop => ActiveState::Inactive,
            UnitContolType::Restart => ActiveState::Active,
            UnitContolType::Reload => ActiveState::Active,
        }
    }
}