Created
July 23, 2025 08:49
-
-
Save Frando/891a533be14a830987bf030e5e96ea5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use irpc::{ | |
| channel::{mpsc, oneshot}, | |
| rpc_requests, | |
| }; | |
| use serde::{Deserialize, Serialize}; | |
| #[derive(Debug, Serialize, Deserialize)] | |
| struct PutRequest { | |
| key: String, | |
| value: String, | |
| } | |
| #[derive(Debug, Serialize, Deserialize)] | |
| struct GetRequest { | |
| key: String, | |
| } | |
| #[rpc_requests(TestMessage, alias = "Msg")] | |
| #[derive(Debug, Serialize, Deserialize)] | |
| enum TestProtocol { | |
| #[rpc(tx = oneshot::Sender<String>)] | |
| Put(PutRequest), | |
| #[rpc(tx = mpsc::Sender<String>)] | |
| Get(GetRequest), | |
| } | |
| fn foo(msg: PutMsg) -> String { | |
| // does not compile! | |
| format!( | |
| "Received Put request with key: {}, value: {}", | |
| msg.inner.key, msg.inner.value | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment