4 releases

0.2.2 Dec 16, 2023
0.2.1 Dec 15, 2023
0.2.0 Dec 11, 2023
0.1.0 Nov 28, 2023

#314 in HTTP client

MIT license

115KB
3K SLoC

rpc-core-net

Build Status Latest version Documentation License

Usage

Run the following Cargo command in your project directory:

cargo add rpc-core-net

Or add the following line to your Cargo.toml:

[dependencies]
rpc-core-net = "0.2.2"

Example

See examples for details: examples

  • server

    fn server() {
        let rpc = Rpc::new(None);
        rpc.subscribe("cmd", |msg: String| -> String {
            assert_eq!(msg, "hello");
            "world".to_string()
        });
      
        let server = rpc_server::RpcServer::new(6666, RpcConfigBuilder::new().rpc(Some(rpc.clone())).build());
        server.start();
    }
    
  • client

    fn client() {
        let rpc = Rpc::new(None);
        let client = rpc_client::RpcClient::new(RpcConfigBuilder::new().rpc(Some(rpc.clone())).build());
        client.set_reconnect(1000);
        client.open("localhost", 6666);
    
        let result = rpc_c.cmd("cmd").msg("hello").future::<String>().await;
        assert_eq!(result.result.unwrap(), "world");
    }
    

License

This project is licensed under the MIT license.

Dependencies

~3–12MB
~135K SLoC