Struct arber::Hash[][src]

pub struct Hash(_);
Expand description

Generic hash type which should be compatible with most hashes used within the blockchain domain.

Implementations

impl Hash[src]

pub const LEN: usize[src]

32 byte hash

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

Return a hash initialized from v.

At most, up to Hash::LEN bytes will be copied from v. If v has less than Hash::LEN bytes, the hash will be padded with 0’s from left to right.

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

Retrun a hash initialized from string hex.

An error is returned, if hex is not a well-formed hex string like "0xcafe".

Trait Implementations

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

fn as_ref(&self) -> &[u8][src]

Performs the conversion.

impl Clone for Hash[src]

fn clone(&self) -> Hash[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Hash[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Decode for Hash[src]

fn decode<__CodecInputEdqy: Input>(
    __codec_input_edqy: &mut __CodecInputEdqy
) -> Result<Self, Error>
[src]

Attempt to deserialise the value from input.

fn skip<I>(input: &mut I) -> Result<(), Error> where
    I: Input
[src]

Attempt to skip the encoded value from input. Read more

fn encoded_fixed_size() -> Option<usize>[src]

Returns the fixed encoded size of the type. Read more

impl Display for Hash[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Encode for Hash[src]

fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
    &self,
    __codec_dest_edqy: &mut __CodecOutputEdqy
)
[src]

Convert self to a slice and append it to the destination.

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

Convert self to an owned vector.

fn using_encoded<R, F: FnOnce(&[u8]) -> R>(&self, f: F) -> R[src]

Convert self to a slice and then invoke the given closure with it.

fn size_hint(&self) -> usize[src]

If possible give a hint of expected size of the encoding. Read more

fn encoded_size(&self) -> usize[src]

Calculates the encoded size. Read more

impl Hashable for Hash[src]

fn hash(&self) -> Hash[src]

Return the hash, without hashing again.

impl PartialEq<Hash> for Hash[src]

fn eq(&self, other: &Hash) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Hash) -> bool[src]

This method tests for !=.

impl Copy for Hash[src]

impl EncodeLike<Hash> for Hash[src]

impl StructuralPartialEq 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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T, U> AsByteSlice<T> for U where
    T: ToByteSlice,
    U: AsRef<[T]> + ?Sized

pub fn as_byte_slice(&self) -> &[u8]

impl<U> AsSliceOf for U where
    U: AsRef<[u8]> + ?Sized

pub fn as_slice_of<T>(&self) -> Result<&[T], Error> where
    T: FromByteSlice, 

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> DecodeAll for T where
    T: Decode
[src]

pub fn decode_all(input: &[u8]) -> Result<T, Error>[src]

Decode Self and consume all of the given input data. Read more

impl<T> DecodeLimit for T where
    T: Decode
[src]

pub fn decode_all_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>[src]

Decode Self and consume all of the given input data. Read more

pub fn decode_with_depth_limit(limit: u32, input: &[u8]) -> Result<T, Error>[src]

Decode Self with the given maximum recursion depth. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> KeyedVec for T where
    T: Codec
[src]

pub fn to_keyed_vec(&self, prepend_key: &[u8]) -> Vec<u8, Global>[src]

Return an encoding of Self prepended by given slice.

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<S> Codec for S where
    S: Decode + Encode
[src]

impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ T> for T where
    T: Encode
[src]

impl<'_, T> EncodeLike<&'_ mut T> for T where
    T: Encode
[src]

impl<T> EncodeLike<Arc<T>> for T where
    T: Encode
[src]

impl<T> EncodeLike<Box<T, Global>> for T where
    T: Encode
[src]

impl<'a, T> EncodeLike<Cow<'a, T>> for T where
    T: ToOwned + Encode
[src]

impl<T> EncodeLike<Rc<T>> for T where
    T: Encode
[src]

impl<S> FullCodec for S where
    S: Decode + FullEncode
[src]

impl<S> FullEncode for S where
    S: Encode + EncodeLike<S>, 
[src]