diff options
| author | tv <tv@krebsco.de> | 2026-11-29 01:24:49 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-29 01:24:49 +0000 |
| commit | f568d97b7ad41bdeeb4d07c61fad468bc83ad3f6 (patch) | |
| tree | 4176b4be5bb27fcc6108a0c32c2da4376576a15f /crates/config/src/units.rs | |
| parent | f10ee79ddc2b0a541f1011aa395990df21e456b5 (diff) | |
config: clap, serde, toml and tracing are features, none default
A program names what it uses of the crate:
* clap: the command line (arguments);
* serde: what the values set are read into (layer::read), and
durations and sizes as fields (units::duration_option, …);
* toml: configuration files in TOML; without it a .toml file is
refused, saying so, and files are JSON;
* tracing: what a source replaces of an earlier one's, logged.
continuum names all four.
Diffstat (limited to 'crates/config/src/units.rs')
| -rw-r--r-- | crates/config/src/units.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/config/src/units.rs b/crates/config/src/units.rs index 1e72da3..61ece46 100644 --- a/crates/config/src/units.rs +++ b/crates/config/src/units.rs @@ -141,6 +141,7 @@ pub fn format_size(bytes: u64) -> String { /// Serde for a `Duration` option: a string as [`parse_duration`] reads it, or a number /// of seconds (configuration files may write either); written as [`format_duration`]. +#[cfg(feature = "serde")] pub mod duration_option { use std::time::Duration; @@ -165,6 +166,7 @@ pub mod duration_option { /// Reads an optional `Duration` in a request (JSON body or query string) as /// [`duration_option`] reads it; absent is `None`. Use as /// `#[serde(default, deserialize_with = "crate::units::optional_duration")]`. +#[cfg(feature = "serde")] pub fn optional_duration<'de, D: serde::Deserializer<'de>>( d: D, ) -> Result<Option<Duration>, D::Error> { @@ -172,6 +174,7 @@ pub fn optional_duration<'de, D: serde::Deserializer<'de>>( } /// Writes an optional `Duration` as [`duration_option`] does; `None` as null. +#[cfg(feature = "serde")] pub fn serialize_optional_duration<S: serde::Serializer>( value: &Option<Duration>, s: S, @@ -184,6 +187,7 @@ pub fn serialize_optional_duration<S: serde::Serializer>( /// Serde for a size option: a string as [`parse_size`] reads it, or a number of bytes; /// written as [`format_size`]. +#[cfg(feature = "serde")] pub mod size_option { use serde::{Deserialize, Deserializer, Serializer, de::Error as _}; use serde_json::Value as JsonValue; |
