muta_protocol/fixed_codec/macro.rs
1#[macro_export]
2macro_rules! impl_default_fixed_codec_for {
3 ($category:ident, [$($type:ident),+]) => (
4 use crate::types::$category;
5
6 $(
7 impl FixedCodec for $category::$type {
8 fn encode_fixed(&self) -> ProtocolResult<bytes::Bytes> {
9 Ok(bytes::Bytes::from(rlp::encode(self)))
10 }
11
12 fn decode_fixed(bytes: bytes::Bytes) -> ProtocolResult<Self> {
13 Ok(rlp::decode(bytes.as_ref()).map_err(FixedCodecError::from)?)
14 }
15 }
16 )+
17 )
18}