rpc-core 0.2.2

a tiny rpc library for rust
Documentation

rpc-core

Build Status Latest version Documentation License

Usage

Run the following Cargo command in your project directory:

cargo add rpc-core

Or add the following line to your Cargo.toml:

[dependencies]
rpc-core = "0.2.2"

Example

See tests for details:

  • receiver

    fn subscribe() {
        rpc_s.subscribe("cmd", |msg: String| -> String {
            assert_eq!(msg, "hello");
            "world".to_string()
        });
    }
    
    
  • sender (callback)

    fn call() {
        rpc_c.cmd("cmd")
            .msg("hello")
            .rsp(|msg: String| {
                assert_eq!(msg, "world");
            })
            .call();
    }
    
  • sender (future)

    async fn call() {
        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.