https://github.com/starcoinorg/openrpc-rs
https://github.com/starcoinorg/openrpc-rs
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/starcoinorg/openrpc-rs
- Owner: starcoinorg
- Created: 2021-01-13T09:31:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-18T14:33:40.000Z (12 months ago)
- Last Synced: 2025-04-14T06:52:49.184Z (6 months ago)
- Language: Rust
- Size: 98.6 KB
- Stars: 2
- Watchers: 13
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* openrpc-rs
Rust implementation of [[https://spec.open-rpc.org/][openrpc Specification]]
* Sub projects
+ [[https://github.com/starcoinorg/openrpc-rs/tree/master/openrpc-schema][openrpc-schema]]
Implement the schema of openrpc. Support to generate openrpc schema documents with the basic functions.
+ [[https://github.com/starcoinorg/openrpc-rs/tree/master/openrpc-derive][openrpc-derive]]Implement a proc macro to generate openrpc schema for rust traits.
* Examples
Baisc Usage
#+begin_src rust
use jsonrpc_core::Error;
use openrpc_derive::openrpc;#[openrpc]
pub trait DebugApi {
#[rpc(name = "debug.panic")]
fn panic(&self, me: String) -> Result;#[rpc(name = "debug.sleep")]
fn sleep(&self, time: u64) -> Result;
}fn main() {
let schema = self::gen_schema();
let j = serde_json::to_string_pretty(&schema).unwrap();
println!("{}", j);
}
#+end_srcWorks with jsonrpc compatibly by adding the "jsonrpc" to the [features] section.
#+begin_src toml
openrpc-derive = {git = "https://github.com/starcoinorg/openrpc-rs",features=["jsonrpc"]}
#+end_src
This can generate both jsonrpc client and server, and openrpc schema.