fix(notify): WatchdogUsec and ExtendTimeoutUsec are in microseconds

This commit is contained in:
Mathieu Trossevin 2024-01-05 22:33:53 +01:00
parent 7d930c3e42
commit f5b9796a32
2 changed files with 10 additions and 9 deletions

View file

@ -230,11 +230,11 @@ pub enum NotifyState<'a> {
/// Tell the service manager to execute the configured watchdog option.
WatchdogTrigger,
/// Reset watchdog timeout value during runtime.
/// The value is in milliseconds.
WatchdogUsec(types::Milliseconds),
/// The value is in microseconds.
WatchdogUsec(types::Microseconds),
/// Tells the service manager to extend the startup, runtime or shutdown service timeout corresponding the current state.
/// The value is in milliseconds.
ExtendTimeoutUsec(types::Milliseconds),
/// The value is in microseconds.
ExtendTimeoutUsec(types::Microseconds),
}
impl<'a> Display for NotifyState<'a> {
@ -254,10 +254,10 @@ impl<'a> Display for NotifyState<'a> {
NotifyState::Stopping => f.write_str("STOPPING=1"),
NotifyState::Watchdog => f.write_str("WATCHDOG=1"),
NotifyState::WatchdogTrigger => f.write_str("WATCHDOG=trigger"),
NotifyState::WatchdogUsec(types::Milliseconds(milliseconds)) => {
NotifyState::WatchdogUsec(types::Microseconds(milliseconds)) => {
write!(f, "WATCHDOG_USEC={milliseconds}")
}
NotifyState::ExtendTimeoutUsec(types::Milliseconds(milliseconds)) => {
NotifyState::ExtendTimeoutUsec(types::Microseconds(milliseconds)) => {
write!(f, "EXTEND_TIMEOUT_USEC={milliseconds}")
}
}

View file

@ -70,16 +70,17 @@ impl AsRef<str> for StatusLine<'_> {
}
}
/// Semantic type representing a number of microseconds.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Milliseconds(pub(super) u64);
pub struct Microseconds(pub(super) u64);
impl From<u64> for Milliseconds {
impl From<u64> for Microseconds {
fn from(value: u64) -> Self {
Self(value)
}
}
impl AsRef<u64> for Milliseconds {
impl AsRef<u64> for Microseconds {
fn as_ref(&self) -> &u64 {
&self.0
}