systemd-transient 0.1.3

Start transient systemd services using dbus, just like systemd-run.
Documentation
use std::time::Duration;

use crate::{SystemdTransientManager, UnitExit, error::SystemdTransientError};

pub struct TransientUnitHandle {
  pub(crate) name: String,
  pub(crate) stop_timeout: Duration,
  pub(crate) manager: SystemdTransientManager,
}

impl TransientUnitHandle {
  pub async fn stop(self) -> Result<(), SystemdTransientError> {
    self.manager.stop(&self.name, self.stop_timeout).await?;
    // TODO: should we assert that the unit was actuallty stopped and not failed already before?
    // TODO: is waiting for the job the same as wait_for_exit?
    //self.manager.wait_for_exit(&self.name).await?;
    Ok(())
  }

  pub async fn wait_for_exit(&self) -> Result<UnitExit, SystemdTransientError> {
    self.manager.wait_for_exit(&self.name).await
  }
}