4 releases (2 breaking)

0.3.1 Jul 21, 2020
0.3.0 Jul 21, 2020
0.2.0 Jul 21, 2020
0.1.0 Jul 21, 2020

#125 in #server-client

MIT license

19KB
378 lines

Knet

A server and a client that can write and read data asynchronously to and from a T-type data derived by the knet-derive crate.

Crates.io MIT licensed

API Docs

Example

#[derive(DeriveKnet, Debug, Clone, Copy)]
enum Data {
  Integer(i32),
  Char(char)
}

Server::write_all(server.0.clone(), Data::Integer(32)).await?;
Server::write(server.0.clone(), Data::Integer(32), 0).await?;
Client::write_all(server.0.clone(), Data::Integer(32)).await?;

loop {
    match receiver.try_next() {
       Ok(Some(event)) => {
            println!("Receive event<T> {:?} ", event);
         }
        Ok(None) => {
            eprintln!("Connection is down");
            break;
        }
        Err(e) => {
            error!("Nothing receive from receiver", e);
        }
    }
}

Dependencies

~7–15MB
~223K SLoC