[][src]Struct grin_core::core::hash::Hash

pub struct Hash(_);

A hash to uniquely (or close enough) identify one of the main blockchain constructs. Used pervasively for blocks, transactions and outputs.

Implementations

impl Hash[src]

pub const LEN: usize[src]

A hash is 32 bytes.

pub fn from_vec(v: &[u8]) -> Hash[src]

Builds a Hash from a byte vector. If the vector is too short, it will be completed by zeroes. If it's too long, it will be truncated.

pub fn to_vec(&self) -> Vec<u8>[src]

Converts the hash to a byte vector

pub fn as_bytes(&self) -> &[u8][src]

Returns a byte slice of the hash contents.

pub fn from_hex(hex: &str) -> Result<Hash, Error>[src]

Convert hex string back to hash.

pub fn to_u64(&self) -> u64[src]

Most significant 64 bits

Trait Implementations

impl AsRef<[u8]> for Hash[src]

impl Clone for Hash[src]

impl Copy for Hash[src]

impl Debug for Hash[src]

impl Default for Hash[src]

impl DefaultHashable for Hash[src]

impl<'de> Deserialize<'de> for Hash[src]

impl Display for Hash[src]

impl Eq for Hash[src]

impl Hash for Hash[src]

impl Index<Range<usize>> for Hash[src]

type Output = [u8]

The returned type after indexing.

impl Index<RangeFrom<usize>> for Hash[src]

type Output = [u8]

The returned type after indexing.

impl Index<RangeFull> for Hash[src]

type Output = [u8]

The returned type after indexing.

impl Index<RangeTo<usize>> for Hash[src]

type Output = [u8]

The returned type after indexing.

impl Index<usize> for Hash[src]

type Output = u8

The returned type after indexing.

impl Ord for Hash[src]

impl PartialEq<Hash> for Hash[src]

impl PartialOrd<Hash> for Hash[src]

impl Readable for Hash[src]

impl Serialize for Hash[src]

impl StructuralEq for Hash[src]

impl StructuralPartialEq for Hash[src]

impl Writeable for Hash[src]

Auto Trait Implementations

impl RefUnwindSafe for Hash

impl Send for Hash

impl Sync for Hash

impl Unpin for Hash

impl UnwindSafe for Hash

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CloneAny for T where
    T: Clone + Any

impl<T> DebugAny for T where
    T: Any + Debug

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<D> Hashed for D where
    D: DefaultHashable
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> PMMRIndexHashable for T where
    T: DefaultHashable
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<H> ShortIdentifiable for H where
    H: Hashed
[src]

fn short_id(&Self, &Hash, u64) -> ShortId[src]

Generate a short_id via the following -

  • extract k0/k1 from block_hash hashed with the nonce (first two u64 values) * initialize a siphasher24 with k0/k1
    • self.hash() passing in the siphasher24 instance
    • drop the 2 most significant bytes (to return a 6 byte short_id)

impl<T> ToHex for T where
    T: AsRef<[u8]>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> UnsafeAny for T where
    T: Any