Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.09 KB

README.md

File metadata and controls

42 lines (34 loc) · 1.09 KB

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);
        }
    }
}