systemprompt-models 0.21.1

Foundation data models for systemprompt.io AI governance infrastructure. Shared DTOs, config, and domain types consumed by every layer of the MCP governance pipeline.
Documentation
//! `SharedRequestContext`: mutex-shared form of `RequestContext` for async
//! tasks.
//!
//! Copyright (c) systemprompt.io — Business Source License 1.1.
//! See <https://systemprompt.io> for licensing details.

use super::context::RequestContext;
use std::sync::{Arc, Mutex};

pub type SharedRequestContext = Arc<Mutex<RequestContext>>;

impl From<RequestContext> for SharedRequestContext {
    fn from(context: RequestContext) -> Self {
        Self::new(Mutex::new(context))
    }
}

impl From<Arc<Mutex<Self>>> for RequestContext {
    fn from(shared: Arc<Mutex<Self>>) -> Self {
        let guard = shared
            .lock()
            .unwrap_or_else(std::sync::PoisonError::into_inner);
        guard.clone()
    }
}