jsonrpc-base

Crates.iojsonrpc-base
lib.rsjsonrpc-base
version0.2.0
sourcesrc
created_at2023-06-19 17:04:12.029546
updated_at2023-06-20 21:50:35.374815
descriptionA minimalistic types implementation of the JSON-RPC protocol
homepage
repositoryhttps://github.com/vlopes11/jsonrpc-base
max_upload_size
id894251
size37,945
Victor Lopes (vlopes11)

documentation

https://docs.rs/jsonrpc-base/

README

jsonrpc-base

A minimalistic types implementation of the JSON-RPC protocol.

crates.io Documentation License

Example

use jsonrpc_base::Request;

let (id, request) = Request::new("foo/barBaz")
    .with_params(vec![1, 2, 3])
    .expect("vec JSON parse will not fail")
    .prepare();

let mut lines = request.lines();
assert_eq!(lines.next(), Some("Content-Length: 100"));
assert_eq!(lines.next(), Some(""));

let mut message = String::new();
message.push_str(r#"{"jsonrpc":"2.0","id":"#);
message.push_str(id.to_string().as_str());
message.push_str(r#","method":"foo/barBaz","params":[1,2,3]}"#);
assert_eq!(lines.next(), Some(message.as_str()));
Commit count: 3

cargo fmt