p2panda-rs 0.9.0

All the things a panda needs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// SPDX-License-Identifier: AGPL-3.0-or-later

//! Interfaces for interactions for hash-like structs.
use crate::hash::Hash;

/// Trait implemented on types which are derived from a hash.
pub trait HashId {
    /// Return the hash this id is derived from.
    fn as_hash(&self) -> &Hash;

    /// Returns hash as bytes.
    fn to_bytes(&self) -> Vec<u8> {
        // Unwrap as we already validated the hash
        hex::decode(self.as_hash().as_str()).unwrap()
    }
}