Post Office

this is a light weight tcp connection manager, including client and server side functions to communicate at high speed long living stable connctions with message que written in Rust.

Installation

put carte name and version in your cargo.toml file under dependencies.

bash postoffice = "*"

Server Usage

```rust

use postoffice::{Request,Response,server};

fn handler(req: Request) -> Result { let message = format!("hello client this is the server {}",req.data); match Response::new(req,message) { Ok(res)=>{ return Ok(res); }, Err()=>{ println!("failed to send response"); return Err("failed to build response".tostring()); } } }

fn auth(token:server::auth::Token) -> bool { println!("token : {:?}",token); return true; }

fn main(){ let key = "8cfb30b34977529853bbe46afdbbd5ae".to_string(); let address = String::from("127.0.0.1:5200"); server::init(address,key,handler,auth); }

```

Client Usage

```rust

use postoffice::client::{gettestmessage,getrandomconnectionid,startconnection,send_message};

fn main(){

let key = "8cfb30b34977529853bbe46afdbbd5ae".tostring(); let connectionid = client::getrandomconnectionid(); let addr = "127.0.0.1:5200".tostring();

match startconnection(&connectionid,addr,key) { Ok()=>{ //println!("connection establishged"); }, Err()=>{ common::error("failed start connection"); } }

let message = gettestmessage(8); match sendmessage(&connectionid, message.clone(), false) { Ok(response)=>{ println!("response final : {:#?}",response); }, Err(_)=>{ common::error("request-failed"); } }

}

```

Please make sure to update tests as appropriate.

License

MIT