wslink-rs 0.0.2

A wslink-compatible WebSocket RPC server runtime for Rust using MessagePack transport.
Documentation

wslink-rs

wslink-rs is a Rust runtime for wslink-compatible WebSocket RPC services.

It provides:

  • wslink handshake/authentication (wslink.hello + shared secret)
  • MessagePack request/response transport
  • RPC registration via #[wslink_rpc]
  • publish support for topic updates

Install

[dependencies]
wslink-rs = "0.0.1"
serde_json = "1"

Quick Example

use wslink_rs::prelude::*;

#[derive(Default)]
struct DemoProtocol;

impl DemoProtocol {
    #[wslink_rpc("math.add")]
    fn add(&self, a: i64, b: i64) -> i64 {
        a + b
    }

    #[wslink_rpc("demo.echo")]
    fn echo(&self, value: serde_json::Value) -> serde_json::Value {
        value
    }
}

impl ServerProtocol for DemoProtocol {
    fn initialize(&mut self, _args: &ServerArgument, config: &mut ServerConfig) {
        config.register_rpcs([Self::add(), Self::echo()]);
    }
}

#[tokio::main]
async fn main() {
    start::<DemoProtocol>().await;
}

Run with:

cargo run -- --host 127.0.0.1 --port 3001 --auth-key wslink-secret

Notes

  • The default feature marcos enables proc-macro support from wslink-rs-marco.
  • ServerArgument.auth_key is applied as the default secret unless overridden in initialize.