Skip to main content

CeilingPolicy

Type Alias CeilingPolicy 

Source
pub type CeilingPolicy = Arc<dyn Fn(&str) -> Ceiling + Send + Sync>;
Expand description

How the host answers “what is the ceiling for this script?” — called on every run, so a changed ceiling takes effect at the next one (and a cached result is cut by crate::name::authority_thread).

use ikigai_script::authority::{Ceiling, CeilingPolicy};
use std::sync::Arc;
// A host reading `<config home>/script-authority/{name}`, failing closed when the file
// is missing or unreadable:
let dir = std::path::PathBuf::from("/etc/my-host/script-authority");
let policy: CeilingPolicy = Arc::new(move |name| {
    std::fs::read_to_string(dir.join(name))
        .ok()
        .and_then(|text| Ceiling::parse(&text).ok())
        .unwrap_or_else(Ceiling::nothing)
});

Aliased Type§

pub struct CeilingPolicy { /* private fields */ }