kumoko

Crates.iokumoko
lib.rskumoko
version0.6.0
sourcesrc
created_at2022-07-24 18:24:18.009555
updated_at2023-06-28 14:43:20.010609
descriptionA simple asynchronous server/client crate built on tokio for easy two-way streaming.
homepage
repositoryhttps://github.com/BR03D/kumoko.git
max_upload_size
id632130
size43,923
(BR03D)

documentation

README

Kumoko

A simple asynchronous server/client crate built on tokio for easy two-way streaming.

crates-badge docs.rs license

Website | API Docs

Unstable Warning!

  • Early in development
  • The documentation is lacking
  • Limited tests

Motivation

Enable asynchronous full duplex streaming of semi-complex data-structures between a rust server and clients. gRPC implementations are suboptimal for this:

  • Unnecessary complexity
  • Annoying Protocol buffers
  • Restricted Data e.g. no enums

Features

  • Many Clients can communicate with the Server asynchronously
  • Every Client has a full duplex connection
  • Any data structure that implements Message can be transmitted:
trait Message: Send + Encode + Decode + 'static

Examples

In your Cargo.toml:

[dependencies]
kumoko = "0.5"
tokio = { version = "1.20", features = ["macros", "rt-multi-thread"] }

Minimal Client:

use kumoko::client::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = Client::connect("[::1]:50052").await?;

    client.emit_request("Ferris".to_string()).await;
    let msg: String = client.get_response().await.unwrap();
    println!("{}", msg);

    Ok(())
}

Minimal Server:

use kumoko::server::Server;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut server = Server::<String, String>::bind("[::1]:50052").await?;
    
    loop{
        let (req, origin) = server.get_request().await;

        let msg = format!("Hello {}! Happy to see you here!", req);
        server.emit_response(msg, origin.into()).await;
    }
}
Commit count: 55

cargo fmt