From 4b51610d9aea5fcfd048004d34df909664f49689 Mon Sep 17 00:00:00 2001 From: Merope Riddle Date: Sun, 23 Oct 2016 14:08:41 +0000 Subject: [PATCH] core: move remaining contents of core/ser.rs into ser.rs --- core/src/core/mod.rs | 1 - core/src/core/ser.rs | 55 -------------------------------------------- core/src/ser.rs | 28 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 56 deletions(-) delete mode 100644 core/src/core/ser.rs diff --git a/core/src/core/mod.rs b/core/src/core/mod.rs index 6be1e7c1d6..cffccadb2b 100644 --- a/core/src/core/mod.rs +++ b/core/src/core/mod.rs @@ -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}; diff --git a/core/src/core/ser.rs b/core/src/core/ser.rs deleted file mode 100644 index f7d726b4dc..0000000000 --- a/core/src/core/ser.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2016 The Grin Developers -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Binary stream serialization and deserialzation for core types from trusted -//! Write or Read implementations. Issues like starvation or too big sends are -//! expected to be handled upstream. - -use time; - -use std::io::{Write, Read}; -use core::{self, hash}; -use ser::*; - -use secp::Signature; -use secp::key::SecretKey; -use secp::pedersen::{Commitment, RangeProof}; - -macro_rules! impl_slice_bytes { - ($byteable: ty) => { - impl AsFixedBytes for $byteable { - fn as_fixed_bytes(&self) -> &[u8] { - &self[..] - } - } - } -} - -impl_slice_bytes!(SecretKey); -impl_slice_bytes!(Signature); -impl_slice_bytes!(Commitment); -impl_slice_bytes!(Vec); - -impl AsFixedBytes for hash::Hash { - fn as_fixed_bytes(&self) -> &[u8] { - self.to_slice() - } -} - -impl AsFixedBytes for RangeProof { - fn as_fixed_bytes(&self) -> &[u8] { - &self.bytes() - } -} - diff --git a/core/src/ser.rs b/core/src/ser.rs index a0c9a607a9..3e08f38354 100644 --- a/core/src/ser.rs +++ b/core/src/ser.rs @@ -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); + +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() + } +} +