From f568d97b7ad41bdeeb4d07c61fad468bc83ad3f6 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 01:24:49 +0000 Subject: config: clap, serde, toml and tracing are features, none default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- crates/config/src/units.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/config/src/units.rs') 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, 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( value: &Option, s: S, @@ -184,6 +187,7 @@ pub fn serialize_optional_duration( /// 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; -- cgit v1.3.1