{"id":27858431,"url":"https://github.com/roboplc/roboplc-rpc","last_synced_at":"2025-05-04T14:10:20.828Z","repository":{"id":269881034,"uuid":"908744916","full_name":"roboplc/roboplc-rpc","owner":"roboplc","description":"Ultra-lightweight Rust JSON RPC 2.0 server and client","archived":false,"fork":false,"pushed_at":"2024-12-27T18:29:49.000Z","size":52,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-01T04:38:42.358Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roboplc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-26T21:18:23.000Z","updated_at":"2024-12-27T18:29:53.000Z","dependencies_parsed_at":"2024-12-26T21:34:47.883Z","dependency_job_id":"f2acaff8-3285-4748-97c4-e47bf1bb24ff","html_url":"https://github.com/roboplc/roboplc-rpc","commit_stats":null,"previous_names":["roboplc/roboplc-rpc"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Froboplc-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Froboplc-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Froboplc-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Froboplc-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roboplc","download_url":"https://codeload.github.com/roboplc/roboplc-rpc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252264516,"owners_count":21720523,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-04T14:10:20.283Z","updated_at":"2025-05-04T14:10:20.819Z","avatar_url":"https://github.com/roboplc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch2\u003e\n  RoboPLC RPC - JSON RPC 2.0 minimalistic server and client\n  \u003ca href=\"https://crates.io/crates/roboplc-rpc\"\u003e\u003cimg alt=\"crates.io page\" src=\"https://img.shields.io/crates/v/roboplc-rpc.svg\"\u003e\u003c/img\u003e\u003c/a\u003e\n  \u003ca href=\"https://docs.rs/roboplc-rpc\"\u003e\u003cimg alt=\"docs.rs page\" src=\"https://docs.rs/roboplc-rpc/badge.svg\"\u003e\u003c/img\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/roboplc/roboplc-rpc/actions/workflows/ci.yml\"\u003e\n    \u003cimg alt=\"GitHub Actions CI\" src=\"https://github.com/roboplc/roboplc-rpc/actions/workflows/ci.yml/badge.svg\"\u003e\u003c/img\u003e\n  \u003c/a\u003e\n\u003c/h2\u003e\n\nJSON RPC 2.0 server and client, part of [RoboPLC](https://www.roboplc.com)\nproject.\n\n## Description\n\nUltra-lightweight JSON RPC 2.0 server and client library. Fully generic\nimplementation, no runtime dispatching, maximum performance and exhaustiveness.\n\nProtocol-agnostic, can be used with any transport layer.\n\nNote: batch requests are not supported as used pretty never in practice. In\ncase if you `really` need them, submit an issue/pull request.\n\n## Example\n\n### Client\n\n```rust\nuse serde::{Serialize, Deserialize};\nuse roboplc_rpc::{client::RpcClient, dataformat};\n\n#[derive(Serialize, Deserialize)]\n// use tag = \"method\", content = \"params\" for the canonical JSON-RPC 2.0\n#[serde(tag = \"m\", content = \"p\", rename_all = \"lowercase\", deny_unknown_fields)]\nenum MyMethod\u003c'a\u003e {\n    Test {},\n    Hello { name: \u0026'a str },\n}\n\n#[derive(Serialize, Deserialize)]\n#[serde(untagged)]\nenum MyResult {\n    General { ok: bool },\n    String(String),\n}\n\nlet client: RpcClient\u003cdataformat::Json, MyMethod, MyResult\u003e = RpcClient::new();\nlet req = client.request(MyMethod::Hello { name: \"world\" }).unwrap();\n// send req.payload() via the chosen transport to the server\n// if response is received, get the result\n// let result = client.handle_response(\u0026response); // returns MyResult or RpcError\n```\n\n### Server\n\n```rust\nuse serde::{Serialize, Deserialize};\nuse roboplc_rpc::{RpcResult, dataformat, server::{RpcServer, RpcServerHandler}};\n\n// use the same types as in the client, e.g. share a common crate\n#[derive(Serialize, Deserialize)]\n#[serde(tag = \"m\", content = \"p\", rename_all = \"lowercase\", deny_unknown_fields)]\nenum MyMethod\u003c'a\u003e {\n    Test {},\n    Hello { name: \u0026'a str },\n}\n\n#[derive(Serialize, Deserialize)]\n#[serde(untagged)]\nenum MyResult {\n    General { ok: bool },\n    String(String),\n}\n\nstruct MyRpc {}\n\nimpl\u003c'a\u003e RpcServerHandler\u003c'a\u003e for MyRpc {\n    type Method = MyMethod\u003c'a\u003e;\n    type Result = MyResult;\n    type Source = std::net::IpAddr;\n\n    fn handle_call(\u0026self, method: MyMethod, source: Self::Source)\n        -\u003e RpcResult\u003cMyResult\u003e {\n        println!(\"Received call from {}\", source);\n        match method {\n            MyMethod::Test {} =\u003e Ok(MyResult::General { ok: true }),\n            MyMethod::Hello { name } =\u003e Ok(MyResult::String(format!(\"Hello, {}\", name))),\n        }\n    }\n}\n\nlet server = roboplc_rpc::server::RpcServer::new(MyRpc {});\n// get the request from the transport\nlet request_payload = r#\"{\"i\":1,\"m\":\"hello\",\"p\":{\"name\":\"world\"}}\"#.as_bytes();\nif let Some(response_payload) = server.handle_request_payload::\u003cdataformat::Json\u003e(\n    request_payload, std::net::IpAddr::V4(std::net::Ipv4Addr::LOCALHOST)) {\n    // send response_payload via the chosen transport to the client. if the\n    // payload is none, either the client does not need a response or the\n    // request was completely invalid (no error can be returned)\n}\n```\n\n## Canonical/minimalistic JSON-RPC 2.0\n\nBy default the crate works in a \"minimalistic\" mode:\n\n* `jsonrpc` field is not required in the request/response, the version is never\n  checked.\n\n* `id`, `method` and `params` request fields are renamed to `i`, `m` and `p`\n  respectively.\n\n* `id`, `result` and `error` response fields are renamed to `i`, `r` and `e`\n  respectively.\n\nThe mode can be changed to JSON-RPC 2.0 canonical by enabling the `canonical`\nfeature.\n\n## Features\n\n* `std` - std support (enabled by default).\n* `msgpack` - enables MessagePack serialization support.\n* `http` - certain tools for HTTP transport (calls via HTTP GET, minimalistic responses).\n* `canonical` - enable canonical JSON-RPC 2.0\n\n## no-std\n\nThis library is `no_std` compatible. Use `--no-default-features` to disable `std` support.\n\n`no-std` mode is still in development, e.g. a std-client can not talk to a\nno-std-server and vice versa.\n\n[heapless::String](https://docs.rs/heapless/latest/heapless/struct.String.html)\nis used for strings instead of the standard one (for error messages).\n\nLimitations:\n\n* Request id can be `u32` only.\n* Provides data types only, no client/server implementations.\n* Error messages can be 128 bytes long only.\n* Request and response data is placed under additional `p` field as\n  [serde](https://serde.rs) does not support `flatten` in `no_std`.\n\n## MSRV\n\n1.68.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froboplc%2Froboplc-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froboplc%2Froboplc-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froboplc%2Froboplc-rpc/lists"}