pub struct ScriptRegistry { /* private fields */ }Expand description
In-memory script registry with optional link-time inventory discovery.
Populated at boot via Self::register_from_inventory or manual Self::register
calls; read by crate::execute_script and crate::Executor.
Implementations§
Source§impl ScriptRegistry
impl ScriptRegistry
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty registry with no registered scripts.
§Examples
use chronon_executor::ScriptRegistry;
let registry = ScriptRegistry::new();
assert!(registry.is_empty());Sourcepub fn from_inventory() -> Self
pub fn from_inventory() -> Self
Populate from all #[chronon::script] descriptors linked into the binary.
Sourcepub fn register_from_inventory(&mut self)
pub fn register_from_inventory(&mut self)
Register every script descriptor collected via link-time inventory.
Sourcepub fn register(&mut self, desc: ScriptDescriptor)
pub fn register(&mut self, desc: ScriptDescriptor)
Inserts or replaces a script descriptor keyed by ScriptDescriptor::name.
Duplicate names overwrite the previous handler without error.
Sourcepub fn get(&self, name: &str) -> Option<ScriptDescriptorRef<'_>>
pub fn get(&self, name: &str) -> Option<ScriptDescriptorRef<'_>>
Returns a borrowed view of the script named name, if registered.
Sourcepub fn get_or_err(&self, name: &str) -> Result<ScriptDescriptorRef<'_>>
pub fn get_or_err(&self, name: &str) -> Result<ScriptDescriptorRef<'_>>
Like Self::get, but returns ChrononError::ScriptNotFound when absent.
Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Returns true when a script with the given name is registered.
Sourcepub fn list(&self) -> Vec<ScriptDescriptorRef<'_>>
pub fn list(&self) -> Vec<ScriptDescriptorRef<'_>>
Returns all registered scripts sorted by name.