pub struct HostContext {
pub plugin_id: String,
pub capabilities: Vec<PluginCapability>,
/* private fields */
}Expand description
Host context provided to plugins
Fields§
§plugin_id: StringPlugin ID
capabilities: Vec<PluginCapability>Plugin capabilities
Implementations§
Source§impl HostContext
impl HostContext
pub fn new(plugin_id: &str, capabilities: Vec<PluginCapability>) -> Self
Sourcepub fn has_capability(&self, cap: &PluginCapability) -> bool
pub fn has_capability(&self, cap: &PluginCapability) -> bool
Check if plugin has a capability
Sourcepub fn require_capability(&self, cap: &PluginCapability) -> WasmResult<()>
pub fn require_capability(&self, cap: &PluginCapability) -> WasmResult<()>
Require a capability, returning error if not present
Sourcepub fn register_function(&mut self, name: &str, callback: HostCallback)
pub fn register_function(&mut self, name: &str, callback: HostCallback)
Register a custom host function
Sourcepub async fn set_config(&self, key: &str, value: WasmValue)
pub async fn set_config(&self, key: &str, value: WasmValue)
Set configuration value
Sourcepub async fn get_config(&self, key: &str) -> Option<WasmValue>
pub async fn get_config(&self, key: &str) -> Option<WasmValue>
Get configuration value
Sourcepub async fn drain_messages(&self) -> Vec<HostMessage>
pub async fn drain_messages(&self) -> Vec<HostMessage>
Get all pending messages
Auto Trait Implementations§
impl Freeze for HostContext
impl !RefUnwindSafe for HostContext
impl Send for HostContext
impl Sync for HostContext
impl Unpin for HostContext
impl UnsafeUnpin for HostContext
impl !UnwindSafe for HostContext
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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