footing 0.6.1

Feature-gated foundations for Rust backend services
Documentation
//! Settings primitives shared by Footing components.
//!
//! This module owns component-level deserialization and invariant validation.
//! Application-level loading, source precedence, metadata, and documentation
//! belong to a configuration framework such as Tier.
//!
//! Component settings expose `validate_at(path)` when their validation produces
//! field paths. Use the component's actual location in the application settings,
//! such as `"database.pool"`; an empty path validates it at the document root.
//! `validate()` uses the component's documented default location instead.
//!
//! ```rust
//! # #[cfg(feature = "postgres")]
//! # {
//! use footing::db::postgres::PostgresPoolSettings;
//!
//! let pool = PostgresPoolSettings::default().with_max_connections(0);
//! let error = pool.validate_at("pool").unwrap_err();
//! assert_eq!(error.issues()[0].path(), "pool.max_connections");
//! let error = pool.validate_at("").unwrap_err();
//! assert_eq!(error.issues()[0].path(), "max_connections");
//! # }
//! ```
//!
//! ```rust
//! use std::time::Duration;
//!
//! use footing::settings::human_duration;
//!
//! let timeout = human_duration::parse("1m30s").unwrap();
//! assert_eq!(timeout, Duration::from_secs(90));
//! ```

pub mod human_duration;
#[cfg(feature = "tier")]
#[cfg_attr(docsrs, doc(cfg(feature = "tier")))]
pub mod tier;
mod validation;

pub use validation::{MAX_SETTINGS_ISSUES, SettingsIssue, SettingsIssues, SettingsValidationError};

#[cfg(any(
    feature = "http-stack",
    feature = "postgres",
    feature = "sqlite",
    feature = "tls",
    feature = "worker"
))]
pub(crate) fn field_path(path: &str, field: &str) -> String {
    if path.is_empty() {
        field.to_owned()
    } else {
        format!("{path}.{field}")
    }
}

#[cfg(test)]
mod tests;