wamp_async

crates.io mio Lines of Code

An asynchronous WAMP client implementation written in rust.

Usage

For usage examples, see :

Structs Serialization and Deserialization

rust // Call endpoint with one argument let (args, kwargs) = client.call("peer.echo", Some(vec![12.into()]), None).await?; // or let (args, kwargs) = client.call("peer.echo", Some(wamp_async::try_into_args((12,))), None).await?; println!("RPC returned {:?} {:?}", args, kwargs);

```rust

[derive(serde::Deserialize, serde::Serialize)]

struct MyKwArgs { name: String, }

// Declare your RPC function async fn rpcecho(args: Option, kwargs: Option) -> Result<(Option, Option), WampError> { // You only need serde-deserializable structure (e.g. a tuple of two integers) let validargs: (i32, i32) = if let Some(args) = args { wampasync::tryfromargs(args)? } else { return Err(wampasync::WampError::UnknownError("positional args are required".tostring())); }; println!("Two integers are: {}, {}", validargs.0, valid_args.1);

// You can also use a custom struct and use a little bit of Rust helpers
let valid_kwargs: Option<MyKwArgs> = kwargs.map(wamp_async::try_from_kwargs).transpose()?;

if let Some(MyKwArgs { name }) = valid_kwargs {
    println!("Name is {}", name);
} else {
    println!("There were no kwargs specified");
}

Ok((
    Some(wamp_async::try_into_args(valid_args)?),
    valid_kwargs.map(wamp_async::try_into_kwargs).transpose()?,
))

}

// Register the function let rpcid = client.register("peer.echo", rpcecho).await?; ```

Features

| Feature | Desciption | Status | | ---------------- | -------------------------------------------------------------------------------------- | ------ | | Websocket | Use websocket as the transport | ✔ | | Secure Websocket | Websocket over HTTPS | ✔ | | RawSocket | Use lightweight TCP as the transport | ✔ | | Secure RawSocket | RawSocket with TLS | ✔ | | MsgPack | Use MessagePack for message serialization | ✔ | | JSON | Uses JSON for message serialization | ✔ |

Client

Basic profile :

| Feature | Desciption | Status | | ---------- | -------------------------------------------- | ------ | | Publisher | Ability to publish messages on topics | ✔ | | Subscriber | Can subscribe and receive events for a topic | ✔ | | Caller | Ability to call RPC endpoints | ✔ | | Callee | Ability to register RPC endpoints | ✔ |

Advanced profile:

| Feature | Desciption | Status | | --------------------- | --------------------------------------------------------------- | ----------- | | Client Authentication | Low-level support for Client Authentication (Ticket-based, CRA) | ✔ | | Progressive Calls | Partial results reported from Callee to Caller | help wanted |

License

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.