Crate zus_rs

Crate zus_rs 

Source
Expand description

§ZUS-RS: ZUS RPC Framework for Rust

zus-rs is a high-performance RPC framework with cross-language compatibility (Rust, Java, C++). It provides service discovery via ZooServer and supports QuickLZ/Snappy compression.

§Features

  • Cross-language RPC: Compatible with Java and C++ implementations
  • Protocol Buffer serialization: Efficient binary protocol
  • Compression: QuickLZ (default) and Snappy support
  • Service Discovery: Integration with ZooServer
  • Async I/O: Built on Tokio runtime
  • Type-safe: Full Rust type safety with protobuf definitions

§Quick Start

§Client Example

[dependencies]
zus-rs = { version = "1.1.4", features = ["client"] }
tokio = { version = "1.35", features = ["full"] }
use zus_rs::prelude::*;

§Server Example

[dependencies]
zus-rs = { version = "1.1.4", features = ["server"] }
tokio = { version = "1.35", features = ["full"] }
use zus_rs::prelude::*;

§Protocol Only (No RPC Runtime)

[dependencies]
zus-rs = { version = "1.1.4", features = ["protocol"] }
use zus_rs::prelude::*;

// Create protocol message
let request = ZooRegisterClientRequest {};

// Use compression types
let _compressor = Compressor::default();
let _comp_type = CompressionType::QuickLZ;

§Feature Flags

Choose the features you need:

FeatureDescriptionIncludes
defaultClient + Server + ProtocolEverything except runtime
minimalProtocol definitions onlyJust zus-proto
protocolProtocol + Codec + Compressionzus-proto, zus-common
clientRPC client functionalityprotocol, zus-rpc-client, zus-discovery
serverRPC server functionalityprotocol, zus-rpc-server, zus-discovery, zus-macros
fullEverythingclient + server

§Examples

# Just client
[dependencies]
zus-rs = { version = "1.1.4", features = ["client"] }

# Just server
[dependencies]
zus-rs = { version = "1.1.4", features = ["server"] }

# Protocol only (no RPC runtime)
[dependencies]
zus-rs = { version = "1.1.4", features = ["protocol"] }

# Minimal (just message definitions)
[dependencies]
zus-rs = { version = "1.1.4", features = ["minimal"] }

# Everything (default)
[dependencies]
zus-rs = "1.1.4"

§Architecture

┌─────────────────────────────────────────┐
│           zus-rs (convenience)          │
└─────────────────────────────────────────┘
                   │
       ┌───────────┼───────────┐
       │           │           │
       ↓           ↓           ↓
  ┌────────┐  ┌────────┐  ┌────────┐
  │ client │  │ server │  │protocol│
  └────────┘  └────────┘  └────────┘
       │           │           │
       ↓           ↓           ↓
  ┌─────────────────────────────────┐
  │  zus-rpc-{client,server}        │
  │  zus-discovery                  │
  │  zus-common (codec/compression) │
  │  zus-proto (protobuf messages)  │
  └─────────────────────────────────┘

§Cross-Language Compatibility

ZUS-RS is wire-compatible with:

  • Java: ZUS Java client/server (tested with integration tests)
  • C++: ZUS C++ client/server (production-tested)

All implementations share:

  • Same 40-byte RPC header format
  • Same Protocol Buffer definitions
  • Same compression algorithms (QuickLZ, Snappy)
  • Same CRC validation (CRC16 header, CRC32 data)

See tests/cross-language/ for comprehensive cross-language test suite.

§Documentation

Re-exports§

pub use zus_proto as proto;
pub use zus_common as common;protocol
pub use zus_discovery as discovery;client or server
pub use zus_rpc_client as client;client
pub use zus_rpc_server as server;server
pub use zus_macros;server

Modules§

prelude
Commonly used types and traits

Structs§

MobileRpcClientclient
Mobile RPC Client (16-byte header protocol)
MobileRpcServerserver
Mobile RPC Server (16-byte header protocol)
RpcClientclient
Convenient type alias for BaseRpcClient
RpcServerserver
Convenient type alias for ZusServerManager

Attribute Macros§

async_traitclient or server