steam_vent/
service_method.rs1use protobuf::Message;
2use std::fmt::Debug;
3use std::io::{Read, Write};
4use steam_vent_proto::{RpcMessage, RpcMethod};
5
6pub trait ServiceMethodRequest: Debug + Message {
7 const REQ_NAME: &'static str;
8 type Response: RpcMessage;
9
10 fn parse(_reader: &mut dyn Read) -> protobuf::Result<Self>;
11 fn write(&self, _writer: &mut dyn Write) -> protobuf::Result<()>;
12 fn encode_size(&self) -> usize;
13}
14
15impl<T: RpcMethod> ServiceMethodRequest for T {
16 const REQ_NAME: &'static str = T::METHOD_NAME;
17 type Response = T::Response;
18
19 fn parse(reader: &mut dyn Read) -> protobuf::Result<Self> {
20 <Self as RpcMessage>::parse(reader)
21 }
22
23 fn write(&self, writer: &mut dyn Write) -> protobuf::Result<()> {
24 <Self as RpcMessage>::write(self, writer)
25 }
26
27 fn encode_size(&self) -> usize {
28 <Self as RpcMessage>::encode_size(self)
29 }
30}