create_sandbox (security/detect.rs)

james_library · src/security/detect.rs · rust · MIT
infra

Factory for creating sandbox instances based on config or auto‑detection.

// Source: https://github.com/topherchris420/james_library | License: MIT | Copyright 2026 Vers3Dynamics
// Provided via justclaw.it.com; keep this notice with the code.
//! Auto-detection of available security features

use crate::config::{SandboxBackend, SecurityConfig};
use crate::security::traits::Sandbox;
use std::sync::Arc;

/// Create a sandbox based on auto-detection or explicit config
pub fn create_sandbox(config: &SecurityConfig) -> Arc<dyn Sandbox> {
    let backend = &config.sandbox.backend;

    // If explicitly disabled, return noop
    if matches!(backend, SandboxBackend::None) || config.sandbox.enabled == Some(false) {
        return Arc::new(super::traits::NoopSandbox);
    }

    // If specific backend requested, try that
    match backend {
        SandboxBackend::Landlo

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key