Expand description
Request-Response wrapper over MPMC Crossbeam channels
This crate is designed for situations where you want to have request-response channels shared
between two or more processes using the crossbeam_channel crate.
§The Left-Right Concept
This crate revolves around the concept of a Left channel pair and a Right channel pair.
You select one process to be the Left and another process to be the Right.
The Left Process holds a Sender<L> type and a Receiver<R> type that sends messages of
type L (the Left process message type) and receives messages of type R (the Right
process message type).
The Right Process is the inverse which holds a Sender<R> type and a Receiver<L> type
that sends messages of type R (the Right process message type) and receives messages of
type L (the Left process message type).
§Example Use Case
You have a process in a thread that listens for connections and receives messages. Another process in another thread consumes these messages and returns a response back to the connection process which will send it back to the connected client. Here, you could have a channel to send the incoming messages to the Message consumer process and another channel to return the response.
This crate allows for you to create these channel pairs so that you can share them between processes easily.
§Too Complicated?
If the Left and Right concept is confusing, you don’t have to use the Bridge at all and
can create queue pairs with the following functions:
unbounded_bridgefor Unbounded channel pairsbounded_bridgefor Bounded channel pairsleft_bounded_bridgefor theSender<L>andReceiver<L>to be bound and theSender<R>andReceiver<R>to be unboundright_bounded_bridgefor theSender<R>andReceiver<R>to be bound and theSender<L>andReceiver<L>to be unbound
This allows you to have full control of the channels and you can implement your logic as you please.
Structs§
- Bridge
- The Bridge containing the
LeftandRightchannels. - Iter
- A blocking iterator over messages in a channel.
- Receiver
- The receiving side of a channel.
- Recv
Error - An error returned from the
recvmethod. - Send
Error - An error returned from the
sendmethod. - Sender
- The sending side of a channel.
- TryIter
- A non-blocking iterator over messages in a channel.
Enums§
- Recv
Timeout Error - An error returned from the
recv_timeoutmethod. - Send
Timeout Error - An error returned from the
send_timeoutmethod. - TryRecv
Error - An error returned from the
try_recvmethod. - TrySend
Error - An error returned from the
try_sendmethod.
Functions§
- bounded_
bridge - Creates two pairs of bounded channels for the
LeftandRighttypes - left_
bounded_ bridge - Creates two pairs of channels for the
LeftandRighttypes with theLeftside bounded. - right_
bounded_ bridge - Creates two pairs of channels for the
LeftandRighttypes with theRightside bounded. - unbounded_
bridge - Creates two pairs of unbounded channels for the
LeftandRighttypes
Type Aliases§
- Left
Channel Split - Channel split containing the
Leftchannels (Sender<L>&Receiver<R>) - Right
Channel Split - Channel split containing the
Rightchannels (Sender<R>&Receiver<L>)