simple-message-channels

Crates.iosimple-message-channels
lib.rssimple-message-channels
version0.2.0
sourcesrc
created_at2019-11-21 17:45:20.471768
updated_at2020-02-07 01:21:02.732539
descriptionSimple binary protocol with a channel, type, message scheme
homepage
repositoryhttps://github.com/datrs/simple-message-channels
max_upload_size
id183267
size50,760
Franz Heinzmann (Frando)

documentation

https://docs.rs/simple-message-channels

README

simple-message-channels

Simple streamable state machine that implements a useful channel, message-type, message pattern.

A port of the JavaScript module simple-message-channels to Rust. Original module by mafintosh.

Examples

See examples/.

The following sends three messages, transforms them, and prints the results:

cargo run --example send | cargo run --example echo_upper | cargo run --example recv

This example would read messages from STDIN and echos them back to STDOUT:

async fn echo() -> Result<(), io::Error> {
    let stdin = io::stdin().lock().await;
    let stdout = io::stdout().lock().await;
    let mut reader = Reader::new(stdin);
    let mut writer = Writer::new(stdout);
    while let Some(msg) = reader.next().await {
        let msg = msg?;
        writer.send(msg).await?;
    }
    Ok(())
}
Commit count: 19

cargo fmt