]> git.bitcoin.ninja Git - rust-lightning/blob - src/util/ser_macros.rs
Expose (de)serialziers as we'll need them and I don't like warnings
[rust-lightning] / src / util / ser_macros.rs
1 macro_rules! impl_writeable {
2         ($st:ident, {$($field:ident),*}) => {
3                 impl<W: ::std::io::Write> Writeable<W> for $st {
4                         fn write(&self, w: &mut Writer<W>) -> Result<(), DecodeError> {
5                                 $( self.$field.write(w)?; )*
6                                 Ok(())
7                         }
8                 }
9
10                 impl<R: ::std::io::Read> Readable<R> for $st {
11                         fn read(r: &mut Reader<R>) -> Result<Self, DecodeError> {
12                                 Ok(Self {
13                                         $($field: Readable::read(r)?),*
14                                 })
15                         }
16                 }
17         }
18 }