#[macro_export] macro_rules! impl_cast_bytes_vec { ($typ:ty, $through:ident) => { impl CastBytes for $typ { fn from_vec(bytes: Vec) -> Self { Self($through::from_vec(bytes)) } fn into_vec(self) -> Vec { self.0.into_vec() } } }; } #[macro_export] macro_rules! impl_from_for_wrapper { ($typ:ty, $through:ty) => { impl From<$through> for $typ { fn from(value: $through) -> Self { Self(value) } } }; } macro_rules! impl_identity { ($typ:ty) => { impl Encode<$typ> for $typ { fn encode(self) -> $typ { self } } impl Decode<$typ> for $typ { fn decode(self) -> anyhow::Result<$typ> { Ok(self) } } }; } macro_rules! impl_wrapper { ($struct:ident) => { impl From for $struct { fn from(value: T) -> Self { Self(value) } } impl CastBytes for $struct { fn from_bytes(bytes: Bytes) -> Self { Self(T::from_bytes(bytes)) } fn into_bytes(self) -> Bytes { self.0.into_bytes() } fn from_vec(vec: Vec) -> Self { Self(T::from_vec(vec)) } fn into_vec(self) -> Vec { self.0.into_vec() } } }; }