mirror of https://github.com/Trivernis/bromine.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
718 B
Rust
27 lines
718 B
Rust
use crate::ipc::stream_emitter::StreamEmitter;
|
|
|
|
/// An object provided to each callback function.
|
|
/// Currently it only holds the event emitter to emit response events in event callbacks.
|
|
/// ```rust
|
|
/// use rmp_ipc::context::Context;
|
|
/// use rmp_ipc::Event;
|
|
/// use rmp_ipc::error::Result;
|
|
///
|
|
/// async fn my_callback(ctx: &Context, _event: Event) -> Result<()> {
|
|
/// // use the emitter on the context object to emit events
|
|
/// // inside callbacks
|
|
/// ctx.emitter.emit("ping", ()).await?;
|
|
/// Ok(())
|
|
/// }
|
|
/// ```
|
|
pub struct Context {
|
|
/// The event emitter
|
|
pub emitter: StreamEmitter,
|
|
}
|
|
|
|
impl Context {
|
|
pub(crate) fn new(emitter: StreamEmitter) -> Self {
|
|
Self { emitter }
|
|
}
|
|
}
|