diff options
| author | tv <tv@krebsco.de> | 2026-10-30 15:10:29 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-30 15:10:29 +0100 |
| commit | 4250d9843133d38c7ace1a1b510265a15ebaa0fd (patch) | |
| tree | 3f996542020c3b44351a765fcf27119bc181f767 /src/units.rs | |
| parent | 65d2118bcc9b7465c8086f2ca9c2b26c8ae7e57c (diff) | |
add dormant-probe-max option
Diffstat (limited to 'src/units.rs')
| -rw-r--r-- | src/units.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/units.rs b/src/units.rs index ac08ebf..28adab9 100644 --- a/src/units.rs +++ b/src/units.rs @@ -171,6 +171,17 @@ pub(crate) fn optional_duration<'de, D: serde::Deserializer<'de>>( duration_option::deserialize(d).map(Some) } +/// Writes an optional `Duration` as [`duration_option`] does; `None` as null. +pub(crate) fn serialize_optional_duration<S: serde::Serializer>( + value: &Option<Duration>, + s: S, +) -> Result<S::Ok, S::Error> { + match value { + Some(value) => duration_option::serialize(value, s), + None => s.serialize_none(), + } +} + /// Serde for a size option: a string as [`parse_size`] reads it, or a number of bytes; /// written as [`format_size`]. pub(crate) mod size_option { |
