plux_rs/context/register_plugin_context.rs
1use std::path::PathBuf;
2
3use crate::Bundle;
4
5/// Context provided during plugin registration.
6///
7/// RegisterPluginContext contains information about a plugin that is being registered
8/// with a manager. It provides access to the plugin's filesystem location and metadata.
9///
10/// # Type Parameters
11///
12/// * `'a` - Lifetime of the references
13///
14/// # Fields
15///
16/// * `path` - Reference to the filesystem path of the plugin file or directory
17/// * `bundle` - Reference to the plugin's bundle metadata (id, version, format)
18///
19/// # Example
20///
21/// ```rust,no_run
22/// use plux_rs::{Manager, RegisterPluginContext, StdInfo, utils::ManagerResult};
23/// use std::path::PathBuf;
24///
25/// struct MyManager;
26///
27/// impl Manager<'_, (), StdInfo> for MyManager {
28/// fn format(&self) -> &'static str { "my" }
29///
30/// fn register_plugin(&mut self, context: RegisterPluginContext) -> ManagerResult<StdInfo> {
31/// println!("Registering plugin: {}", context.bundle.id);
32/// println!("Plugin path: {:?}", context.path);
33///
34/// Ok(StdInfo::new())
35/// }
36/// }
37/// ```
38pub struct RegisterPluginContext<'a> {
39 /// Filesystem path to the plugin file or directory
40 pub path: &'a PathBuf,
41 /// Plugin bundle metadata (id, version, format)
42 pub bundle: &'a Bundle,
43}