proxmox-rest-server: cleanup formatter, improve docs

Use trait for OutputFormatter. This is functionally equivalent,
but more rust-like...
This commit is contained in:
Dietmar Maurer
2021-09-27 12:59:06 +02:00
parent 8a23ea4656
commit 53daae8e89
8 changed files with 128 additions and 98 deletions

View File

@ -1,4 +1,4 @@
//! Helpers for daemons/services.
//! Helpers to implement restartable daemons/services.
use std::ffi::CString;
use std::future::Future;
@ -351,6 +351,7 @@ extern "C" {
fn sd_notify(unset_environment: c_int, state: *const c_char) -> c_int;
}
/// Systemd sercice startup states (see: ``man sd_notify``)
pub enum SystemdNotify {
Ready,
Reloading,
@ -359,6 +360,7 @@ pub enum SystemdNotify {
MainPid(nix::unistd::Pid),
}
/// Tells systemd the startup state of the service (see: ``man sd_notify``)
pub fn systemd_notify(state: SystemdNotify) -> Result<(), Error> {
let message = match state {
SystemdNotify::Ready => CString::new("READY=1"),