pub struct PluginContext { /* private fields */ }Expand description
Context passed to a plugin. Registrations are automatically owned by its scope and survive when their returned handles are ignored.
Implementations§
Source§impl PluginContext
impl PluginContext
pub fn isolate<K: ServiceKey>(&self) -> Self
pub fn provide<K: ServiceKey>( &self, value: Arc<K::Value>, ) -> Result<ServiceHandle<K>>
pub fn on<E, H, Fut>(&self, handler: H) -> Result<ListenerHandle>
pub fn on_query<Q, H, Fut>(&self, handler: H) -> Result<ListenerHandle>
pub fn defer<F, Fut>(&self, cleanup: F) -> Result<()>
pub fn manage<R: Resource>(&self, resource: R) -> Result<()>
Sourcepub fn spawn<F, Fut>(&self, task: F) -> Result<TaskHandle>
pub fn spawn<F, Fut>(&self, task: F) -> Result<TaskHandle>
Registers a cooperative task. It is spawned only when the activation commits. Disposal waits five seconds, then aborts an unresponsive task.
Methods from Deref<Target = Context>§
pub fn scope_id(&self) -> u64
Sourcepub fn isolate<K: ServiceKey>(&self) -> Self
pub fn isolate<K: ServiceKey>(&self) -> Self
Creates a child where service K resolves in a fresh isolated slot;
all other service types continue to inherit their current slots.
pub fn get<K: ServiceKey>(&self) -> Result<Arc<K::Value>>
pub fn try_get<K: ServiceKey>(&self) -> Option<Arc<K::Value>>
Sourcepub async fn emit<E: Event>(&self, event: E) -> Result<()>
pub async fn emit<E: Event>(&self, event: E) -> Result<()>
Invokes listeners serially in registration order.
Trait Implementations§
Source§impl Clone for PluginContext
impl Clone for PluginContext
Source§fn clone(&self) -> PluginContext
fn clone(&self) -> PluginContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PluginContext
impl RefUnwindSafe for PluginContext
impl Send for PluginContext
impl Sync for PluginContext
impl Unpin for PluginContext
impl UnsafeUnpin for PluginContext
impl UnwindSafe for PluginContext
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