Simplify serialization a bit by removing the useless newtypes
[rust-lightning] / src / util / ser_macros.rs
1 macro_rules! impl_writeable {
2         ($st:ident, {$($field:ident),*}) => {
3                 impl<W: Writer> Writeable<W> for $st {
4                         fn write(&self, w: &mut W) -> Result<(), DecodeError> {
5                                 $( self.$field.write(w)?; )*
6                                 Ok(())
7                         }
8                 }
9
10                 impl<R: Read> Readable<R> for $st {
11                         fn read(r: &mut R) -> Result<Self, DecodeError> {
12                                 Ok(Self {
13                                         $($field: Readable::read(r)?),*
14                                 })
15                         }
16                 }
17         }
18 }