Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
repr(C) for hash types
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 23, 2020
1 parent 6e22bd8 commit 4f5e805
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hash160.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use Error;
/// Output of the Bitcoin HASH160 hash function
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with="crate::util::json_hex_string::len_20"))]
[u8; 20]
Expand Down
1 change: 1 addition & 0 deletions src/hmac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use Error;
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "schemars", schemars(transparent))]
#[repr(transparent)]
pub struct Hmac<T: HashTrait>(T);

impl<T: HashTrait + str::FromStr> str::FromStr for Hmac<T> {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ macro_rules! hash_newtype {
($newtype:ident, $hash:ty, $len:expr, $docs:meta, $reverse:expr) => {
#[$docs]
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct $newtype($hash);

hex_fmt_impl!(Debug, $newtype);
Expand Down
1 change: 1 addition & 0 deletions src/ripemd160.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl EngineTrait for HashEngine {
/// Output of the RIPEMD160 hash function
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with="util::json_hex_string::len_20"))]
[u8; 20]
Expand Down
1 change: 1 addition & 0 deletions src/sha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl EngineTrait for HashEngine {
/// Output of the SHA1 hash function
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with="util::json_hex_string::len_20"))]
[u8; 20]
Expand Down
1 change: 1 addition & 0 deletions src/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl EngineTrait for HashEngine {
/// Output of the SHA256 hash function
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with="util::json_hex_string::len_32"))]
[u8; 32]
Expand Down
1 change: 1 addition & 0 deletions src/sha256d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use Error;
/// Output of the SHA256d hash function
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with="crate::util::json_hex_string::len_32"))]
[u8; 32]
Expand Down
1 change: 1 addition & 0 deletions src/sha256t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub trait Tag {

/// Output of the SHA256t hash function.
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash<T: Tag>(
#[cfg_attr(feature = "schemars", schemars(schema_with="crate::util::json_hex_string::len_32"))]
[u8; 32],
Expand Down
1 change: 1 addition & 0 deletions src/sha512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl EngineTrait for HashEngine {

/// Output of the SHA256 hash function
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with="util::json_hex_string::len_64"))]
[u8; 64]
Expand Down
1 change: 1 addition & 0 deletions src/siphash24.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ impl EngineTrait for HashEngine {
/// Output of the SipHash24 hash function.
#[derive(Copy, Clone, PartialEq, Eq, Default, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[repr(transparent)]
pub struct Hash(
#[cfg_attr(feature = "schemars", schemars(schema_with="util::json_hex_string::len_8"))]
[u8; 8]
Expand Down

0 comments on commit 4f5e805

Please sign in to comment.