pub struct PluginManager<U: UserStorage, S: SessionStorage> { /* private fields */ }Expand description
Manages a collection of plugins.
Implementations§
Source§impl<U: UserStorage, S: SessionStorage> PluginManager<U, S>
impl<U: UserStorage, S: SessionStorage> PluginManager<U, S>
Sourcepub fn new(user_storage: Arc<U>, session_storage: Arc<S>) -> Self
pub fn new(user_storage: Arc<U>, session_storage: Arc<S>) -> Self
Creates a new empty plugin manager.
§Example
use torii_core::PluginManager;
let plugin_manager = PluginManager::new();Sourcepub fn get_plugin<T: Plugin + 'static>(&self, name: &str) -> Option<Arc<T>>
pub fn get_plugin<T: Plugin + 'static>(&self, name: &str) -> Option<Arc<T>>
Gets a plugin instance by its type.
§Example
use torii_core::{PluginManager, Plugin};
struct MyPlugin;
impl Plugin for MyPlugin { /* ... */ }
let mut plugin_manager = PluginManager::new();
plugin_manager.register(MyPlugin);
let plugin = plugin_manager.get_plugin::<MyPlugin>("my_plugin");Sourcepub fn register_plugin<T: Plugin + 'static>(&mut self, plugin: T)
pub fn register_plugin<T: Plugin + 'static>(&mut self, plugin: T)
Registers a new plugin with the plugin manager.
§Example
use torii_core::{PluginManager, Plugin};
struct MyPlugin;
impl Plugin for MyPlugin { /* ... */ }
let mut plugin_manager = PluginManager::new();
plugin_manager.register(MyPlugin);pub fn user_storage(&self) -> &Arc<U>
pub fn session_storage(&self) -> &Arc<S>
Sourcepub async fn start_session_cleanup_task(&self, config: SessionCleanupConfig)
pub async fn start_session_cleanup_task(&self, config: SessionCleanupConfig)
Starts a background task to cleanup expired sessions.
§Example
use torii_core::PluginManager;
use torii_core::SessionCleanupConfig;
let plugin_manager = PluginManager::new();
plugin_manager.start_session_cleanup_task(SessionCleanupConfig::default());Auto Trait Implementations§
impl<U, S> Freeze for PluginManager<U, S>
impl<U, S> !RefUnwindSafe for PluginManager<U, S>
impl<U, S> Send for PluginManager<U, S>
impl<U, S> Sync for PluginManager<U, S>
impl<U, S> Unpin for PluginManager<U, S>
impl<U, S> !UnwindSafe for PluginManager<U, S>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.