[][src]Struct rr_mux::mux::Mux

pub struct Mux<ReqId, Target, Req, Resp, E, Ctx> { /* fields omitted */ }

Mux is a futures based request response multiplexer. This provides a Source interface to drain messages sent, and receives messages via the handle() method, allowing responses to be consumed and requests forwarded on.

ReqId is the request ReqId type Target is the target for the Req or Resp to be sent to Req and Resp are the request and response messages Ctx is a a shared context

Methods

impl<ReqId, Target, Req, Resp, E, Ctx> Mux<ReqId, Target, Req, Resp, E, Ctx> where
    ReqId: Eq + Hash + Debug + Clone + Send + 'static,
    Target: Debug + Send + 'static,
    Req: Debug + Send + 'static,
    Resp: Debug + Send + 'static,
    E: Debug + Send + 'static,
    Ctx: Debug + Clone + Send + 'static, 
[src]

pub fn new() -> Mux<ReqId, Target, Req, Resp, E, Ctx>[src]

Create a new mux over the provided sender

pub fn handle(
    &mut self,
    id: ReqId,
    addr: Target,
    message: Muxed<Req, Resp>
) -> Result<Option<(Target, Req)>, E>
[src]

Handle a muxed received message This either returns a pending response or passes request messages on

pub fn handle_resp(
    &mut self,
    id: ReqId,
    _target: Target,
    resp: Resp
) -> Result<(), E>
[src]

Handle a pre-decoded response message

Trait Implementations

impl<ReqId, Target, Req, Resp, E, Ctx> Clone for Mux<ReqId, Target, Req, Resp, E, Ctx> where
    ReqId: Eq + Hash + Debug + Clone + Send + 'static,
    Target: Debug + Send + 'static,
    Req: Debug + Send + 'static,
    Resp: Debug + Send + 'static,
    E: Debug + Send + 'static,
    Ctx: Debug + Clone + Send + 'static, 
[src]

impl<ReqId, Target, Req, Resp, E, Ctx> Connector<ReqId, Target, Req, Resp, E, Ctx> for Mux<ReqId, Target, Req, Resp, E, Ctx> where
    ReqId: Eq + Hash + Debug + Clone + Send + 'static,
    Target: Debug + Send + 'static,
    Req: Debug + Send + 'static,
    Resp: Debug + Send + 'static,
    E: Debug + Send + 'static,
    Ctx: Debug + Clone + Send + 'static, 
[src]

fn request<'life0, 'async_trait>(
    &'life0 mut self,
    ctx: Ctx,
    id: ReqId,
    addr: Target,
    req: Req
) -> Pin<Box<dyn Future<Output = Result<Resp, E>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Send and register a request

impl<ReqId, Target, Req, Resp, E, Ctx> Stream for Mux<ReqId, Target, Req, Resp, E, Ctx>[src]

type Item = (ReqId, Target, Muxed<Req, Resp>, Ctx)

Values yielded by the stream.

Auto Trait Implementations

impl<ReqId, Target, Req, Resp, E, Ctx> !RefUnwindSafe for Mux<ReqId, Target, Req, Resp, E, Ctx>

impl<ReqId, Target, Req, Resp, E, Ctx> Send for Mux<ReqId, Target, Req, Resp, E, Ctx> where
    Ctx: Send,
    E: Send,
    Req: Send,
    ReqId: Send,
    Resp: Send,
    Target: Send

impl<ReqId, Target, Req, Resp, E, Ctx> Sync for Mux<ReqId, Target, Req, Resp, E, Ctx> where
    Ctx: Send + Sync,
    E: Sync,
    Req: Send + Sync,
    ReqId: Send,
    Resp: Send,
    Target: Send + Sync

impl<ReqId, Target, Req, Resp, E, Ctx> Unpin for Mux<ReqId, Target, Req, Resp, E, Ctx> where
    Ctx: Unpin,
    E: Unpin,
    Req: Unpin,
    Target: Unpin

impl<ReqId, Target, Req, Resp, E, Ctx> !UnwindSafe for Mux<ReqId, Target, Req, Resp, E, Ctx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.