Struct rscript::ScriptManager [−][src]
pub struct ScriptManager { /* fields omitted */ }
Expand description
ScriptManager holds all the scripts found, it can be constructed with ScriptManager::default
Initially its empty, to populate it, we can use one of the methods to add scripts, currently only ScriptManager::add_scripts_by_path is provided
Implementations
Look for scripts in the specified folder
It requires specifying a VersionReq so the script manager can check for incompatibility and if that’s the case it will return an error: Error::ScriptVersionMismatch
The script manager will send a Message::Greeting for every script found and the scripts must respond with ScriptInfo
let mut sm = ScriptManager::default();
let scripts_path: std::path::PathBuf = todo!(); // Defined by the user
const VERSION: &'static str = concat!("main_crate-", env!("CARGO_PKG_VERSION"));
sm.add_scripts_by_path(scripts_path, Version::parse(VERSION).expect("version is correct"));
Same as ScriptManager::add_scripts_by_path but looks for dynamic libraries instead
Safety
See https://docs.rs/libloading/0.7.1/libloading/struct.Library.html#safety
Trigger a hook All scripts that are active and that are listening for this particular hook will receive it
Mutable list of current scripts, useful for activating/deactivating a script
Trait Implementations
Returns the “default value” for a type. Read more