Struct rmp_ipc::ipc::builder::IPCBuilder [−][src]
pub struct IPCBuilder { /* fields omitted */ }
Expand description
A builder for the IPC server or client.
use typemap_rev::TypeMapKey;
use rmp_ipc::IPCBuilder;
struct CustomKey;
impl TypeMapKey for CustomKey {
type Value = String;
}
IPCBuilder::new()
.address("127.0.0.1:2020")
// register callback
.on("ping", |_ctx, _event| Box::pin(async move {
println!("Received ping event.");
Ok(())
}))
// register a namespace
.namespace("namespace")
.on("namespace-event", |_ctx, _event| Box::pin(async move {
println!("Namespace event.");
Ok(())
}))
.build()
// add context shared data
.insert::<CustomKey>("Hello World".to_string())
// can also be build_client which would return an emitter for events
.build_server().await.unwrap();
Implementations
Adds globally shared data
Adds an event callback
Adds a namespace
Adds a namespace to the ipc server
Builds an ipc server
Builds an ipc client
Builds a pooled IPC client
This causes the builder to actually create pool_size
clients and
return a crate::context::PooledContext that allows one to crate::context::PooledContext::acquire a single context
to emit events.
Auto Trait Implementations
impl !RefUnwindSafe for IPCBuilder
impl Send for IPCBuilder
impl Sync for IPCBuilder
impl Unpin for IPCBuilder
impl !UnwindSafe for IPCBuilder
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more