[][src]Macro fixed_hash::construct_fixed_hash

macro_rules! construct_fixed_hash {
    ( $(#[$attr:meta])* $visibility:vis struct $name:ident ( $n_bytes:expr ); ) => { ... };
}

Construct a fixed-size hash type.

Examples

Create a public unformatted hash type with 32 bytes size.

construct_fixed_hash!{ pub struct H256(32); }

With additional attributes and doc comments.

// Add the below two lines to import serde and its derive
// extern crate serde;
// #[macro_use] extern crate serde_derive;
construct_fixed_hash!{
	/// My unformatted 160 bytes sized hash type.
	#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
	pub struct H160(20);
}

The visibility modifier is optional and you can create a private hash type.

construct_fixed_hash!{ struct H512(64); }