pub struct TransientUnitHandle { /* private fields */ }Expand description
Holds a reference on the unit (AddRef=true), so systemd keeps it loaded
after it exits. Release it with release or by dropping
the handle; until then, starting a unit of the same name fails with
UnitStillLoaded.
Implementations§
Source§impl TransientUnitHandle
impl TransientUnitHandle
Sourcepub async fn stop(&self) -> Result<UnitExit, SystemdTransientError>
pub async fn stop(&self) -> Result<UnitExit, SystemdTransientError>
Stops the unit and returns the state it ended in. If the unit had
already exited, nothing is stopped and that earlier state is returned.
If someone else started the unit again since, it is left running and
UnitRestarted is returned, unless this run’s exit was already seen.
The handle’s reference keeps the name from being reused, but the unit
itself can be started again (systemctl start). The invocation ID check
keeps this call from stopping that later run. A restart between the
check and StopUnit is not caught.
pub fn name(&self) -> &str
Sourcepub async fn wait_for_exit(&self) -> Result<UnitExit, SystemdTransientError>
pub async fn wait_for_exit(&self) -> Result<UnitExit, SystemdTransientError>
Resolves once the unit has exited, even if that happened before this
call. Several tasks may wait at once, also while another one calls
stop.
Sourcepub async fn release(self) -> Result<(), SystemdTransientError>
pub async fn release(self) -> Result<(), SystemdTransientError>
Drops the reference on the unit, so systemd can collect it once it is inactive. Does not stop the unit.