Relicense as dual Apache-2.0 + MIT
[rust-lightning] / lightning / src / util / ser_macros.rs
index 766d4ee2d78ff90a774049e8cc13d9731b490d18..ceabcc1ddbeb385666c909943842d01d61887b91 100644 (file)
@@ -1,3 +1,12 @@
+// This file is Copyright its original authors, visible in version control
+// history.
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
 macro_rules! encode_tlv {
        ($stream: expr, {$(($type: expr, $field: expr)),*}) => { {
                use util::ser::{BigSize, LengthCalculatingWriter};
@@ -116,8 +125,8 @@ macro_rules! impl_writeable {
                        }
                }
 
-               impl<R: ::std::io::Read> ::util::ser::Readable<R> for $st {
-                       fn read(r: &mut R) -> Result<Self, ::ln::msgs::DecodeError> {
+               impl ::util::ser::Readable for $st {
+                       fn read<R: ::std::io::Read>(r: &mut R) -> Result<Self, ::ln::msgs::DecodeError> {
                                Ok(Self {
                                        $($field: ::util::ser::Readable::read(r)?),*
                                })
@@ -137,8 +146,8 @@ macro_rules! impl_writeable_len_match {
                        }
                }
 
-               impl<R: ::std::io::Read> Readable<R> for $st {
-                       fn read(r: &mut R) -> Result<Self, DecodeError> {
+               impl ::util::ser::Readable for $st {
+                       fn read<R: ::std::io::Read>(r: &mut R) -> Result<Self, DecodeError> {
                                Ok(Self {
                                        $($field: Readable::read(r)?),*
                                })
@@ -152,7 +161,7 @@ mod tests {
        use std::io::{Cursor, Read};
        use ln::msgs::DecodeError;
        use util::ser::{Readable, Writeable, HighZeroBytesDroppedVarInt, VecWriter};
-       use secp256k1::PublicKey;
+       use bitcoin::secp256k1::PublicKey;
 
        // The BOLT TLV test cases don't include any tests which use our "required-value" logic since
        // the encoding layer in the BOLTs has no such concept, though it makes our macros easier to
@@ -219,9 +228,9 @@ mod tests {
                        (0xdeadbeef1badbeef, 0x1bad1dea, Some(0x01020304)));
        }
 
-       impl<R: Read> Readable<R> for (PublicKey, u64, u64) {
+       impl Readable for (PublicKey, u64, u64) {
                #[inline]
-               fn read(reader: &mut R) -> Result<(PublicKey, u64, u64), DecodeError> {
+               fn read<R: Read>(reader: &mut R) -> Result<(PublicKey, u64, u64), DecodeError> {
                        Ok((Readable::read(reader)?, Readable::read(reader)?, Readable::read(reader)?))
                }
        }