Crate mrsc

Source
Expand description

mpsc with requests

§Examples

use mrsc;
use std::thread;

let server: mrsc::Server<u32, String> = mrsc::Server::new();
let channel = server.pop();

thread::spawn(move || {
    let req = server.recv().unwrap();
    let reply = {
        let msg = req.get();
        assert_eq!(msg, &123);
        "world".to_string()
    };
    req.reply(reply).unwrap();
});

let response = channel.req(123).unwrap();
let reply = response.recv().unwrap();
assert_eq!(reply, "world".to_string());

Structs§

Channel
A channel to the server that can be used to send requests
EmptyRequest
A request without payload
Request
The request as seen by the server thread
Response
The response returned to an request
Server
The server that receives requests and creates channels

Type Aliases§

RecvError
RecvTimeoutError
SendError
TryRecvError