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 the address to connect to

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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