From 96da4e2e7adab012380cb759679a9856fc127051 Mon Sep 17 00:00:00 2001 From: Gav <gavin@parity.io> Date: Fri, 19 Jan 2018 21:32:11 +0100 Subject: [PATCH] Docs and licence. --- substrate/primitives/src/ed25519.rs | 16 ++++++++++++++++ substrate/primitives/src/hashing.rs | 18 ++++++++++++++++++ substrate/primitives/src/hexdisplay.rs | 22 ++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/substrate/primitives/src/ed25519.rs b/substrate/primitives/src/ed25519.rs index cdbbc194c79..b28e0bde6e2 100644 --- a/substrate/primitives/src/ed25519.rs +++ b/substrate/primitives/src/ed25519.rs @@ -1,3 +1,19 @@ +// Copyright 2017 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. + //! Simple Ed25519 API. use untrusted; diff --git a/substrate/primitives/src/hashing.rs b/substrate/primitives/src/hashing.rs index b21e06391ea..f82ec7ef8bf 100644 --- a/substrate/primitives/src/hashing.rs +++ b/substrate/primitives/src/hashing.rs @@ -1,3 +1,21 @@ +// Copyright 2017 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. + +//! Hashing functions. + use blake2_rfc; use twox_hash; diff --git a/substrate/primitives/src/hexdisplay.rs b/substrate/primitives/src/hexdisplay.rs index 708d5e05289..d6299a2e41d 100644 --- a/substrate/primitives/src/hexdisplay.rs +++ b/substrate/primitives/src/hexdisplay.rs @@ -1,6 +1,26 @@ +// Copyright 2017 Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. + +//! Wrapper type for byte collections that outputs hex. + +/// Simple wrapper to display hex representation of bytes. pub struct HexDisplay<'a>(&'a [u8]); impl<'a> HexDisplay<'a> { + /// Create new instance that will display `d` as a hex string when displayed. pub fn from(d: &'a AsBytesRef) -> Self { HexDisplay(d.as_bytes_ref()) } } @@ -13,7 +33,9 @@ impl<'a> ::std::fmt::Display for HexDisplay<'a> { } } +/// Simple trait to transferm various types to `&[u8]` pub trait AsBytesRef { + /// Transferm `self` into `&[u8]`. fn as_bytes_ref(&self) -> &[u8]; } -- GitLab