liteguard 0.7.20260603

Feature guards, observability, and security response in a single import. Evaluated locally, zero network overhead per check
Documentation
/// Internal result from [`evaluate_guard_detailed`](crate::evaluation::evaluate_guard_detailed).
pub(crate) struct DetailedEvalResult {
    pub result: bool,
    pub matched_rule_index: i64,
}

/// A lightweight execution correlation handle.
///
/// Groups telemetry signals under a shared execution ID. Created by
/// [`Scope::start_execution`](crate::client::Scope::start_execution) or
/// [`Client::start_execution`](crate::client::Client::start_execution).
///
/// Call [`end`](Execution::end) when the logical execution boundary is complete.
pub struct Execution {
    execution_id: String,
    cleanup: Option<Box<dyn FnOnce() + Send>>,
}

impl Execution {
    pub(crate) fn new(execution_id: String, cleanup: impl FnOnce() + Send + 'static) -> Self {
        Self {
            execution_id,
            cleanup: Some(Box::new(cleanup)),
        }
    }

    /// The unique identifier for this execution.
    pub fn execution_id(&self) -> &str {
        &self.execution_id
    }

    /// End this execution. After calling `end()`, subsequent guard checks
    /// will no longer be correlated with this execution.
    pub fn end(mut self) {
        if let Some(cleanup) = self.cleanup.take() {
            cleanup();
        }
    }
}

impl Drop for Execution {
    fn drop(&mut self) {
        if let Some(cleanup) = self.cleanup.take() {
            cleanup();
        }
    }
}