Skip to content

starcoinorg/openrpc-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openrpc-rs

Rust implementation of openrpc Specification

Sub projects

  • openrpc-schema

    Implement the schema of openrpc. Support to generate openrpc schema documents with the basic functions.

  • openrpc-derive

    Implement a proc macro to generate openrpc schema for rust traits.

Examples

Baisc Usage

use jsonrpc_core::Error;
use openrpc_derive::openrpc;

#[openrpc]
pub trait DebugApi {
    
    #[rpc(name = "debug.panic")]
    fn panic(&self, me: String) -> Result<String, Error>;

    #[rpc(name = "debug.sleep")]
    fn sleep(&self, time: u64) -> Result<String, Error>;
}

fn main() {
    let schema = self::gen_schema();
    let j = serde_json::to_string_pretty(&schema).unwrap();
    println!("{}", j);
}

Works with jsonrpc compatibly by adding the “jsonrpc” to the [features] section.

openrpc-derive = {git = "https://github.com/starcoinorg/openrpc-rs",features=["jsonrpc"]}

This can generate both jsonrpc client and server, and openrpc schema.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages