pub struct LoaderContext<'a, 'b, O: Send + Sync, I: Info> { /* private fields */ }
Expand description
Context for configuring the plugin loader.
LoaderContext provides a fluent interface for setting up the plugin loader with managers, functions, and requests. It ensures proper initialization order and provides convenient methods for loader configuration.
§Type Parameters
'a
- Lifetime for references within the loader'b
- Lifetime of the loader referenceO
- Output type for plugin functions (must implement Send + Sync)I
- Plugin information type (must implement Info trait)
§Fields
loader
- Mutable reference to the underlying loader
§Example
ⓘ
use plux_rs::prelude::*;
use plux_custom_manager::CustomManager;
#[plux_rs::function]
fn my_function(_: ()) {
// Function implementation
}
let mut loader = Loader::new();
loader.context(|mut ctx| {
// Register a manager
ctx.register_manager(CustomManager::new())?;
// Register functions and requests
ctx.register_function(my_function());
ctx.register_request(Request::new("main".to_string(), vec![], None));
Ok(())
});
Implementations§
Source§impl<'a, 'b, O: Send + Sync, I: Info> LoaderContext<'a, 'b, O, I>
impl<'a, 'b, O: Send + Sync, I: Info> LoaderContext<'a, 'b, O, I>
Sourcepub fn register_manager<M>(
&mut self,
manager: M,
) -> Result<(), RegisterManagerError>where
M: Manager<'a, O, I> + 'static,
pub fn register_manager<M>(
&mut self,
manager: M,
) -> Result<(), RegisterManagerError>where
M: Manager<'a, O, I> + 'static,
Registers a plugin manager with the loader.
This method registers a manager that can handle plugins of a specific format.
§Parameters
manager
- The manager instance to register
§Returns
Returns Result<(), RegisterManagerError>
indicating success or failure.
§Type Parameters
M
- Type of the manager (must implement Manager trait)
Sourcepub fn register_managers<M>(
&mut self,
managers: M,
) -> Result<(), RegisterManagerError>
pub fn register_managers<M>( &mut self, managers: M, ) -> Result<(), RegisterManagerError>
Sourcepub fn register_request(&mut self, request: Request)
pub fn register_request(&mut self, request: Request)
Registers a function request with the loader.
Function requests define the interface that plugins must implement.
§Parameters
request
- The request to register
Sourcepub fn register_requests<IT>(&mut self, requests: IT)where
IT: IntoIterator<Item = Request>,
pub fn register_requests<IT>(&mut self, requests: IT)where
IT: IntoIterator<Item = Request>,
Sourcepub fn register_function<F>(&mut self, function: F)where
F: Function<Output = O> + 'static,
pub fn register_function<F>(&mut self, function: F)where
F: Function<Output = O> + 'static,
Sourcepub fn register_functions<F, IT>(&mut self, functions: IT)where
F: Function<Output = O> + 'static,
IT: IntoIterator<Item = F>,
pub fn register_functions<F, IT>(&mut self, functions: IT)where
F: Function<Output = O> + 'static,
IT: IntoIterator<Item = F>,
Auto Trait Implementations§
impl<'a, 'b, O, I> Freeze for LoaderContext<'a, 'b, O, I>
impl<'a, 'b, O, I> !RefUnwindSafe for LoaderContext<'a, 'b, O, I>
impl<'a, 'b, O, I> Send for LoaderContext<'a, 'b, O, I>
impl<'a, 'b, O, I> Sync for LoaderContext<'a, 'b, O, I>
impl<'a, 'b, O, I> Unpin for LoaderContext<'a, 'b, O, I>
impl<'a, 'b, O, I> !UnwindSafe for LoaderContext<'a, 'b, O, I>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more