pub struct Context {
pub emitter: StreamEmitter,
pub data: Arc<RwLock<TypeMap>>,
/* private fields */
}
Expand description
An object provided to each callback function. Currently it only holds the event emitter to emit response events in event callbacks.
use rmp_ipc::prelude::*;
async fn my_callback(ctx: &Context, _event: Event) -> IPCResult<()> {
// use the emitter on the context object to emit events
// inside callbacks
ctx.emitter.emit("ping", ()).await?;
Ok(())
}
Fields§
§emitter: StreamEmitter
The event emitter
data: Arc<RwLock<TypeMap>>
Field to store additional context data
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
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