|
@@ -308,7 +308,7 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
|
|
|
self.manager().state().set(state);
|
|
|
}
|
|
|
|
|
|
- /// Gets the managed state for the type `T`.
|
|
|
+ /// Gets the managed state for the type `T`. Panics if the type is not managed.
|
|
|
fn state<T>(&self) -> State<'_, T>
|
|
|
where
|
|
|
T: Send + Sync + 'static,
|
|
@@ -316,6 +316,14 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
|
|
|
self.manager().inner.state.get()
|
|
|
}
|
|
|
|
|
|
+ /// Tries to get the managed state for the type `T`. Returns `None` if the type is not managed.
|
|
|
+ fn try_state<T>(&self) -> Option<State<'_, T>>
|
|
|
+ where
|
|
|
+ T: Send + Sync + 'static,
|
|
|
+ {
|
|
|
+ self.manager().inner.state.try_get()
|
|
|
+ }
|
|
|
+
|
|
|
/// Adds a plugin to the runtime.
|
|
|
fn plugin<P: plugin::Plugin<R> + 'static>(&self, plugin: P) {
|
|
|
self
|