cmdproto 0.1.0

Protobuf message definitions for WebSocket-based applications
Documentation

cmdproto

cmdproto contains protobuf message definitions and Rust helpers for a WebSocket command protocol.

The crate exposes generated protobuf types, command IDs, and small encode/decode helpers for the two packet directions:

  • PacketTos: client to server
  • PacketToc: server to client, with error_code

Usage

use cmdproto::{decode_packet_tos, decode_payload, encode_tos, Cmd, M1001Tos};

let req = M1001Tos {
    username: "alice".into(),
    password: "secret".into(),
};

let bytes = encode_tos(Cmd::Cmd1001 as u32, 1, &req)?;
let packet = decode_packet_tos(&bytes)?;
let decoded: M1001Tos = decode_payload(&packet.payload)?;

assert_eq!(decoded.username, "alice");
# Ok::<(), cmdproto::Error>(())

Protocol Layout

The protobuf schemas are included in the crate under proto/ and compiled at build time with prost-build.

Consumers of this Rust crate do not need to copy the .proto files or add their own build.rs.

License

MIT