Struct exonum::crypto::Hash
[−]
[src]
pub struct Hash(_);
SHA-256 hash.
Examples
use exonum::crypto::{self, Hash}; let data = [1, 2, 3]; let hash_from_data = crypto::hash(&data); let default_hash = Hash::default();
Methods
impl Hash
[src]
impl Hash
[src]
pub fn new(ba: [u8; 32]) -> Self
[src]
Creates a new instance from bytes array.
pub fn from_slice(bs: &[u8]) -> Option<Self>
[src]
Creates a new instance from bytes slice.
pub fn to_hex(&self) -> String
[src]
Returns the hex representation of the binary data. Lower case letters are used (e.g. f9b4ca).
Trait Implementations
impl<'a> ExonumJson for &'a Hash
[src]
fn deserialize_field<B: WriteBufferWrapper>(
value: &Value,
buffer: &mut B,
from: Offset,
to: Offset
) -> Result<(), Box<Error>>
[src]
value: &Value,
buffer: &mut B,
from: Offset,
to: Offset
) -> Result<(), Box<Error>>
write deserialized field in buffer on place.
fn serialize_field(&self) -> Result<Value, Box<Error + Send + Sync>>
[src]
serialize field as json::Value
impl ExonumJsonDeserialize for Hash
[src]
impl<'a> Field<'a> for &'a Hash
[src]
fn field_size() -> Offset
[src]
Field's header size
unsafe fn read(buffer: &'a [u8], from: Offset, _: Offset) -> &'a Hash
[src]
Read Field from buffer, with given position, beware of memory unsafety, you should check
Field
before read
. Read more
fn write(&self, buffer: &mut Vec<u8>, from: Offset, to: Offset)
[src]
Write Field to buffer, in given position write
doesn't lead to memory unsafety. Read more
fn check(
_: &'a [u8],
from: CheckedOffset,
to: CheckedOffset,
latest_segment: CheckedOffset
) -> Result
[src]
_: &'a [u8],
from: CheckedOffset,
to: CheckedOffset,
latest_segment: CheckedOffset
) -> Result
Checks if data in the buffer could be deserialized. Returns an index of latest data seen. Read more
impl PartialEq for Hash
[src]
fn eq(&self, __arg_0: &Hash) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Hash) -> bool
[src]
This method tests for !=
.
impl Eq for Hash
[src]
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 Copy for Hash
[src]
impl PartialOrd for Hash
[src]
fn partial_cmp(&self, __arg_0: &Hash) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &Hash) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &Hash) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &Hash) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &Hash) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for Hash
[src]
fn cmp(&self, __arg_0: &Hash) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Hash for Hash
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl AsRef<[u8]> for Hash
[src]
impl FromStr for Hash
[src]
type Err = FromHexError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl ToString for Hash
[src]
impl Debug for Hash
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl FromHex for Hash
[src]
type Error = FromHexError
fn from_hex<T: AsRef<[u8]>>(v: T) -> Result<Self, Self::Error>
[src]
Creates an instance of type Self
from the given hex string, or fails with a custom error type. Read more
impl Serialize for Hash
[src]
fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Hash
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Index<Range<usize>> for Hash
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, _index: Range<usize>) -> &[u8]
[src]
Performs the indexing (container[index]
) operation.
impl Index<RangeTo<usize>> for Hash
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, _index: RangeTo<usize>) -> &[u8]
[src]
Performs the indexing (container[index]
) operation.
impl Index<RangeFrom<usize>> for Hash
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, _index: RangeFrom<usize>) -> &[u8]
[src]
Performs the indexing (container[index]
) operation.
impl Index<RangeFull> for Hash
[src]
type Output = [u8]
The returned type after indexing.
fn index(&self, _index: RangeFull) -> &[u8]
[src]
Performs the indexing (container[index]
) operation.
impl Default for Hash
[src]
Returns a hash consisting of zeros.
impl CryptoHash for Hash
[src]
impl StorageKey for Hash
[src]
fn size(&self) -> usize
[src]
Returns the size of the serialized key in bytes.
fn write(&self, buffer: &mut [u8])
[src]
Serializes the key into the specified buffer of bytes. Read more
fn read(buffer: &[u8]) -> Self::Owned
[src]
Deserializes the key from the specified buffer of bytes.
impl StorageValue for Hash
[src]
fn into_bytes(self) -> Vec<u8>
[src]
Serialize a value into a vector of bytes.
fn from_bytes(value: Cow<[u8]>) -> Self
[src]
Deserialize a value from bytes.