workflow_rpc/lib.rs
1//!
2//! [<img alt="github" src="https://img.shields.io/badge/github-workflow--rs-8da0cb?style=for-the-badge&labelColor=555555&color=8da0cb&logo=github" height="20">](https://github.com/workflow-rs/workflow-rpc)
3//! [<img alt="crates.io" src="https://img.shields.io/crates/v/workflow-rpc.svg?maxAge=2592000&style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/workflow-rpc)
4//! [<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-workflow--rpc-56c2a5?maxAge=2592000&style=for-the-badge&logo=docs.rs" height="20">](https://docs.rs/workflow-rpc)
5//! <img alt="license" src="https://img.shields.io/crates/l/workflow-rpc.svg?maxAge=2592000&color=6ac&style=for-the-badge&logoColor=fff" height="20">
6//! <img src="https://img.shields.io/badge/platform: client-native-informational?style=for-the-badge&color=50a0f0" height="20">
7//! <img src="https://img.shields.io/badge/platform: client-wasm32 (web) -informational?style=for-the-badge&color=50a0f0" height="20">
8//! <img src="https://img.shields.io/badge/platform: server-native-informational?style=for-the-badge&color=50a0f0" height="20">//!
9//! async Rust-centric RPC framework supporting a custom high-performance `Borsh` and an extended `JSON-RPC` protocols.
10//!
11//! Features:
12//! - High-performance Borsh message encoding protocol
13//! - RPC method and notification handler declarations based on serializable generics
14//! - Client to Server RPC method invocation
15//! - Client to Server notification messages
16//! - Server to Client notification messages
17//! - Server-side handshake scaffolding for custom connection negotiation
18//! - Easy to retain connection data structure for posting async client notifications
19//!
20//! This framework provides [`server`] and [`client`] modules. The server infrastructure is built on top of
21//! [Tokio](https://crates.io/crates/tokio) and [Tungtenite](https://crates.io/crates/tungstenite) and
22//! provides scaffolding for connection handshake negotiation.
23//!
24//! The client is built on top of [Workflow WebSocket](https://crates.io/crates/workflow-websocket) and
25//! operates uniformly in native applications and in the browser WASM environment. For native applications
26//! Workflow Websocket uses Tokio and Tungstenite and in the browser environment it uses the browser
27//! `WebSocket` object.
28//!
29//!
30//! ### Client-side
31//! ```ignore
32//! interface.notification(
33//! TestOps::Notify,
34//! notification!(|notification: TestNotify| async move {
35//! // handle notification
36//! Ok(())
37//! }),
38//! );
39//!
40//! let resp: MyResponse = rpc.call(MyOps::MyMethod, MethodRequest { ... }).await?;
41//! ```
42//! ### Server-side
43//! ```ignore
44//! interface.method(
45//! TestOps::SomeRequest,
46//! method!(|connection_ctx, server_ctx, request: TestReq| async move {
47//! // handle request and return a response
48//! Ok(SomeResponse { })
49//! }),
50//! );
51//!
52//! interface.notification(
53//! TestOps::Notify,
54//! notification!(
55//! |connection_ctx, server_ctx, notification: TestNotify| async move {
56//! // handle notification
57//! Ok(())
58//! }
59//! ),
60//! );
61//!
62//! ```
63//!
64
65extern crate self as workflow_rpc;
66
67pub mod client;
68pub mod error;
69pub mod id;
70mod imports;
71pub mod messages;
72pub mod result;
73pub mod types;
74
75pub mod encoding;
76#[cfg(not(any(target_arch = "wasm32", target_arch = "bpf")))]
77pub mod server;