Skip to content

Commit

Permalink
core: move remaining contents of core/ser.rs into ser.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
merope07 committed Oct 23, 2016
1 parent 82adc54 commit 4b51610
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 56 deletions.
1 change: 0 additions & 1 deletion core/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pub mod hash;
pub mod transaction;
#[allow(dead_code)]
#[macro_use]
mod ser;

pub use self::block::{Block, BlockHeader};
pub use self::transaction::{Transaction, Input, Output, TxProof};
Expand Down
55 changes: 0 additions & 55 deletions core/src/core/ser.rs

This file was deleted.

28 changes: 28 additions & 0 deletions core/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,31 @@ impl<'a> Writer for BinWriter<'a> {
self.sink.write_all(bs).err().map(Error::IOErr)
}
}

macro_rules! impl_slice_bytes {
($byteable: ty) => {
impl AsFixedBytes for $byteable {
fn as_fixed_bytes(&self) -> &[u8] {
&self[..]
}
}
}
}

impl_slice_bytes!(::secp::key::SecretKey);
impl_slice_bytes!(::secp::Signature);
impl_slice_bytes!(::secp::pedersen::Commitment);
impl_slice_bytes!(Vec<u8>);

impl AsFixedBytes for ::core::hash::Hash {
fn as_fixed_bytes(&self) -> &[u8] {
self.to_slice()
}
}

impl AsFixedBytes for ::secp::pedersen::RangeProof {
fn as_fixed_bytes(&self) -> &[u8] {
&self.bytes()
}
}

0 comments on commit 4b51610

Please sign in to comment.