add UnitHandle, so a unit still can be passed around even though unloaded
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a1ebd63a7b
commit
0a7c43ea6a
1 changed files with 43 additions and 1 deletions
|
@ -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…
Reference in a new issue