example_muxio_rpc_service_definition/prebuffered/
echo.rs1use muxio_rpc_service::{prebuffered::RpcMethodPrebuffered, rpc_method_id};
2use std::io;
3
4pub struct Echo;
5
6impl RpcMethodPrebuffered for Echo {
7 const METHOD_ID: u64 = rpc_method_id!("echo");
8
9 type Input = Vec<u8>;
10 type Output = Vec<u8>;
11
12 fn encode_request(input: Self::Input) -> Result<Vec<u8>, io::Error> {
13 Ok(input)
14 }
15
16 fn decode_request(request_bytes: &[u8]) -> Result<Self::Input, io::Error> {
17 Ok(request_bytes.to_vec())
18 }
19
20 fn encode_response(output: Self::Output) -> Result<Vec<u8>, io::Error> {
21 Ok(output)
22 }
23
24 fn decode_response(response_bytes: &[u8]) -> Result<Self::Output, io::Error> {
25 Ok(response_bytes.to_vec())
26 }
27}