exonum_derive

Derive Macro ObjectHash

Source
#[derive(ObjectHash)]
Expand description

Derives ObjectHash trait. The target type must implement BinaryValue trait.

§Example

#[protobuf_convert(source = "proto::Wallet")]
#[derive(Clone, Debug, ProtobufConvert, BinaryValue, ObjectHash)]
pub struct Wallet {
    /// `PublicKey` of the wallet.
    pub pub_key: PublicKey,
    /// Current balance of the wallet.
    pub balance: u64,
}

let wallet = Wallet {
    pub_key: KeyPair::random().public_key(),
    balance: 100,
};
let hash = wallet.object_hash();