servlet 1.0.0

A small application runtime with an explicit operational contract
Documentation
//! Configuration failures with stable, non-secret diagnostics.

use std::fmt;

/// A configuration constraint that must be resolved before startup.
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum ConfigError {
    /// An unknown or invalid environment setting; only the key is retained.
    Environment(String),
    /// A required capacity or duration is zero.
    ZeroValue(&'static str),
    /// Exchange capacity exceeds the semaphore implementation limit.
    CapacityTooLarge,
    /// A duration cannot be represented as a monotonic deadline.
    UnrepresentableBudget(&'static str),
    /// The cleanup reserve leaves no positive drain budget.
    CleanupReserveExhaustsShutdown,
    /// Both listeners would bind the same or an overlapping nonzero port.
    ConflictingListeners,
    /// A non-loopback administrative listener lacks explicit opt-in.
    RemoteAdminRequiresOptIn,
}

impl fmt::Display for ConfigError {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            Self::Environment(key) => {
                write!(formatter, "unknown or invalid environment setting: {key}")
            }
            Self::CapacityTooLarge => {
                formatter.write_str("max_in_flight exceeds the supported capacity")
            }
            Self::UnrepresentableBudget(field) => {
                write!(formatter, "{field} cannot form a monotonic deadline")
            }
            Self::ZeroValue(field) => write!(formatter, "{field} must be greater than zero"),
            Self::CleanupReserveExhaustsShutdown => {
                formatter.write_str("cleanup_reserve must be less than shutdown_timeout")
            }
            Self::ConflictingListeners => {
                formatter.write_str("application and administrative listeners must not overlap")
            }
            Self::RemoteAdminRequiresOptIn => {
                formatter.write_str("a non-loopback admin_bind requires allow_remote_admin")
            }
        }
    }
}

impl std::error::Error for ConfigError {}

#[cfg(test)]
#[path = "error_test.rs"]
mod error_test;