add UnitHandle, so a unit still can be passed around even though unloaded
continuous-integration/drone/push Build is passing Details

master
eater 5 years ago
parent a1ebd63a7b
commit 0a7c43ea6a
Signed by: eater
GPG Key ID: AD2560A0F84F0759

@ -1,11 +1,39 @@
use crate::unit::JobMode::Replace;
use crate::time::{TimeSpan, FiniteTimeSpan};
use crate::time::TimeSpan::Infinite;
use crate::unit::UnitState::Stopped;
use crate::unit::UnitState::{Stopped, Unloaded};
use crate::config::Config;
use crate::unit::JobMode::{Fail, ReplaceIrreversibly, Isolate, Flush, IgnoreDependencies, IgnoreRequirements};
use crate::unit::CollectMode::{Inactive, InactiveOrFailed};
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Clone)]
pub struct UnitHandle {
name: String,
config: Option<Unit>,
}
impl UnitHandle {
pub fn is_loaded(&self) -> bool {
self.config.is_some()
}
pub fn get_state(&self) -> UnitState {
if let Some(unit) = &self.config {
unit.state
} else {
Unloaded
}
}
pub fn get_config(&self) -> Option<&Unit> {
if let Some(ref unit) = self.config {
Some(unit)
} else {
None
}
}
}
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Clone)]
pub struct Unit {
name: String,
@ -290,6 +318,7 @@ pub enum UnitState {
Stopped,
Failed,
Running,
Unloaded,
}
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Copy, Clone)]
@ -366,6 +395,19 @@ pub enum UnitActionSeverity {
Immediate,
}
pub enum UnitType {
Service,
Socket,
Device,
Mount,
AutoMount,
Swap,
Target,
Path,
Slice,
Scope,
}
#[cfg(test)]
mod tests {
use super::*;

Loading…
Cancel
Save