soaprs-http 0.6.0

Transport-neutral HTTP contracts and policies for soaprs
Documentation
//! Runtime enforcement capabilities required by endpoint declarations.

use std::fmt;

/// External runtime behavior that a framework adapter must actively provide.
///
/// These capabilities are distinct from response policies implemented directly
/// by an adapter and from observational telemetry. An endpoint declaring one of
/// these behaviors must not be served when no installed extension provides it.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum HttpEnforcementCapability {
    /// Credential extraction, authentication, and authorization.
    Authentication,
    /// Evaluation of logical request contracts.
    RequestValidation,
    /// Enforcement of the declared request quota.
    RateLimit,
    /// Cross-origin request and preflight enforcement.
    Cors,
    /// Cross-site request-forgery validation.
    Csrf,
}

impl fmt::Display for HttpEnforcementCapability {
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
        formatter.write_str(match self {
            Self::Authentication => "authentication",
            Self::RequestValidation => "request validation",
            Self::RateLimit => "rate limiting",
            Self::Cors => "CORS",
            Self::Csrf => "CSRF",
        })
    }
}