Struct H160

#[repr(C)]
pub struct H160(pub [u8; 20]);
Expand description

Fixed-size uninterpreted hash type with 20 bytes (160 bits) size.

Tuple Fields§

§0: [u8; 20]

Implementations§

§

impl H160

pub const fn repeat_byte(byte: u8) -> H160

Returns a new fixed hash where all bits are set to the given byte.

pub const fn zero() -> H160

Returns a new zero-initialized fixed hash.

pub const fn len_bytes() -> usize

Returns the size of this hash in bytes.

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

Extracts a byte slice containing the entire fixed hash.

pub fn as_bytes_mut(&mut self) -> &mut [u8]

Extracts a mutable byte slice containing the entire fixed hash.

pub const fn as_fixed_bytes(&self) -> &[u8; 20]

Extracts a reference to the byte array containing the entire fixed hash.

pub fn as_fixed_bytes_mut(&mut self) -> &mut [u8; 20]

Extracts a reference to the byte array containing the entire fixed hash.

pub const fn to_fixed_bytes(self) -> [u8; 20]

Returns the inner bytes array.

pub fn as_ptr(&self) -> *const u8

Returns a constant raw pointer to the value.

pub fn as_mut_ptr(&mut self) -> *mut u8

Returns a mutable raw pointer to the value.

pub fn assign_from_slice(&mut self, src: &[u8])

Assign the bytes from the byte slice src to self.

§Note

The given bytes are interpreted in big endian order.

§Panics

If the length of src and the number of bytes in self do not match.

pub fn from_slice(src: &[u8]) -> H160

Create a new fixed-hash from the given slice src.

§Note

The given bytes are interpreted in big endian order.

§Panics

If the length of src and the number of bytes in Self do not match.

pub fn covers(&self, b: &H160) -> bool

Returns true if all bits set in b are also set in self.

pub fn is_zero(&self) -> bool

Returns true if no bits are set.

§

impl H160

Utilities using the byteorder crate.

pub fn to_low_u64_be(&self) -> u64

Returns the lowest 8 bytes interpreted as big-endian.

§Note

For hash type with less than 8 bytes the missing bytes are interpreted as being zero.

pub fn to_low_u64_le(&self) -> u64

Returns the lowest 8 bytes interpreted as little-endian.

§Note

For hash type with less than 8 bytes the missing bytes are interpreted as being zero.

pub fn to_low_u64_ne(&self) -> u64

Returns the lowest 8 bytes interpreted as native-endian.

§Note

For hash type with less than 8 bytes the missing bytes are interpreted as being zero.

pub fn from_low_u64_be(val: u64) -> H160

Creates a new hash type from the given u64 value.

§Note
  • The given u64 value is interpreted as big endian.
  • Ignores the most significant bits of the given value if the hash type has less than 8 bytes.

pub fn from_low_u64_le(val: u64) -> H160

Creates a new hash type from the given u64 value.

§Note
  • The given u64 value is interpreted as little endian.
  • Ignores the most significant bits of the given value if the hash type has less than 8 bytes.

pub fn from_low_u64_ne(val: u64) -> H160

Creates a new hash type from the given u64 value.

§Note
  • The given u64 value is interpreted as native endian.
  • Ignores the most significant bits of the given value if the hash type has less than 8 bytes.
§

impl H160

Utilities using the rand crate.

pub fn randomize_using<R>(&mut self, rng: &mut R)
where R: Rng + ?Sized,

Assign self to a cryptographically random value using the given random number generator.

pub fn randomize(&mut self)

Assign self to a cryptographically random value.

pub fn random_using<R>(rng: &mut R) -> H160
where R: Rng + ?Sized,

Create a new hash with cryptographically random content using the given random number generator.

pub fn random() -> H160

Create a new hash with cryptographically random content.

Trait Implementations§

§

impl AsMut<[u8]> for H160

§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
§

impl AsRef<[u8]> for H160

§

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

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<'l, 'r> BitAnd<&'r H160> for &'l H160

§

type Output = H160

The resulting type after applying the & operator.
§

fn bitand(self, rhs: &'r H160) -> <&'l H160 as BitAnd<&'r H160>>::Output

Performs the & operation. Read more
§

impl BitAnd for H160

§

type Output = H160

The resulting type after applying the & operator.
§

fn bitand(self, rhs: H160) -> <H160 as BitAnd>::Output

Performs the & operation. Read more
§

impl<'r> BitAndAssign<&'r H160> for H160

§

fn bitand_assign(&mut self, rhs: &'r H160)

Performs the &= operation. Read more
§

impl BitAndAssign for H160

§

fn bitand_assign(&mut self, rhs: H160)

Performs the &= operation. Read more
§

impl<'l, 'r> BitOr<&'r H160> for &'l H160

§

type Output = H160

The resulting type after applying the | operator.
§

fn bitor(self, rhs: &'r H160) -> <&'l H160 as BitOr<&'r H160>>::Output

Performs the | operation. Read more
§

impl BitOr for H160

§

type Output = H160

The resulting type after applying the | operator.
§

fn bitor(self, rhs: H160) -> <H160 as BitOr>::Output

Performs the | operation. Read more
§

impl<'r> BitOrAssign<&'r H160> for H160

§

fn bitor_assign(&mut self, rhs: &'r H160)

Performs the |= operation. Read more
§

impl BitOrAssign for H160

§

fn bitor_assign(&mut self, rhs: H160)

Performs the |= operation. Read more
§

impl<'l, 'r> BitXor<&'r H160> for &'l H160

§

type Output = H160

The resulting type after applying the ^ operator.
§

fn bitxor(self, rhs: &'r H160) -> <&'l H160 as BitXor<&'r H160>>::Output

Performs the ^ operation. Read more
§

impl BitXor for H160

§

type Output = H160

The resulting type after applying the ^ operator.
§

fn bitxor(self, rhs: H160) -> <H160 as BitXor>::Output

Performs the ^ operation. Read more
§

impl<'r> BitXorAssign<&'r H160> for H160

§

fn bitxor_assign(&mut self, rhs: &'r H160)

Performs the ^= operation. Read more
§

impl BitXorAssign for H160

§

fn bitxor_assign(&mut self, rhs: H160)

Performs the ^= operation. Read more
§

impl Clone for H160

§

fn clone(&self) -> H160

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for H160

§

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

Formats the value using the given formatter. Read more
§

impl Decodable for H160

§

fn decode(rlp: &Rlp<'_>) -> Result<H160, DecoderError>

Decode a value from RLP bytes
§

impl Default for H160

§

fn default() -> H160

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for H160

§

fn deserialize<D>( deserializer: D, ) -> Result<H160, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for H160

§

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

Formats the value using the given formatter. Read more
§

impl Encodable for H160

§

fn rlp_append(&self, s: &mut RlpStream)

Append a value to the stream
§

fn rlp_bytes(&self) -> BytesMut

Get rlp-encoded bytes for this instance
§

impl<'a> From<&'a [u8; 20]> for H160

§

fn from(bytes: &'a [u8; 20]) -> H160

Constructs a hash type from the given reference to the bytes array of fixed length.

§Note

The given bytes are interpreted in big endian order.

Source§

impl From<&H160> for Account

Source§

fn from(script_hash: &H160) -> Self

Converts to this type from the input type.
Source§

impl From<&H160> for ContractParameter

Source§

fn from(value: &H160) -> Self

Converts to this type from the input type.
§

impl<'a> From<&'a mut [u8; 20]> for H160

§

fn from(bytes: &'a mut [u8; 20]) -> H160

Constructs a hash type from the given reference to the mutable bytes array of fixed length.

§Note

The given bytes are interpreted in big endian order.

§

impl From<[u8; 20]> for H160

§

fn from(bytes: [u8; 20]) -> H160

Constructs a hash type from the given bytes array of fixed length.

§Note

The given bytes are interpreted in big endian order.

§

impl From<H160> for [u8; 20]

§

fn from(s: H160) -> [u8; 20]

Converts to this type from the input type.
Source§

impl From<H160> for Account

Source§

fn from(script_hash: H160) -> Self

Converts to this type from the input type.
Source§

impl From<H160> for ContractParameter

Source§

fn from(value: H160) -> Self

Converts to this type from the input type.
§

impl From<H160> for H256

§

fn from(value: H160) -> H256

Converts to this type from the input type.
Source§

impl From<H160> for StackItem

Source§

fn from(value: H160) -> Self

Converts to this type from the input type.
§

impl From<H256> for H160

§

fn from(value: H256) -> H160

Converts to this type from the input type.
§

impl FromStr for H160

§

fn from_str(input: &str) -> Result<H160, FromHexError>

Creates a hash type instance from the given string.

§Note

The given input string is interpreted in big endian.

§Errors
  • When encountering invalid non hex-digits
  • Upon empty string input or invalid input length in general
§

type Err = FromHexError

The associated error which can be returned from parsing.
§

impl Hash for H160

§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl<I> Index<I> for H160
where I: SliceIndex<[u8]>,

§

type Output = <I as SliceIndex<[u8]>>::Output

The returned type after indexing.
§

fn index(&self, index: I) -> &<I as SliceIndex<[u8]>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<I> IndexMut<I> for H160
where I: SliceIndex<[u8], Output = [u8]>,

§

fn index_mut(&mut self, index: I) -> &mut <I as SliceIndex<[u8]>>::Output

Performs the mutable indexing (container[index]) operation. Read more
§

impl LowerHex for H160

§

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

Formats the value using the given formatter. Read more
Source§

impl NeoSerializable for H160

Source§

type Error = CodecError

Source§

fn size(&self) -> usize

Source§

fn encode(&self, writer: &mut Encoder)

Source§

fn decode(reader: &mut Decoder<'_>) -> Result<Self, Self::Error>
where Self: Sized,

Source§

fn to_array(&self) -> Vec<u8>

§

impl Ord for H160

§

fn cmp(&self, other: &H160) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for H160

§

fn eq(&self, other: &H160) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for H160

§

fn partial_cmp(&self, other: &H160) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl ScriptHashExtension for H160

Source§

fn to_bs58_string(&self) -> String

Returns a string representation of the object.
Source§

fn zero() -> Self

Creates an instance for a zero-value hash. Returns a zero-value hash
Source§

fn from_slice(slice: &[u8]) -> Result<Self, TypeError>

Creates an instance from a byte slice. Read more
Source§

fn from_hex(hex: &str) -> Result<Self, FromHexError>

Creates an instance from a hex string. Read more
Source§

fn from_address(address: &str) -> Result<Self, TypeError>

Creates an instance from an address string representation. Read more
Source§

fn to_address(&self) -> String

Converts the object into its address string representation.
Source§

fn to_hex(&self) -> String

Converts the object into its hex string representation.
Source§

fn to_hex_big_endian(&self) -> String

Converts the object into its hex string representation.
Source§

fn to_vec(&self) -> Vec<u8>

Converts the object into a byte vector.
Source§

fn to_le_vec(&self) -> Vec<u8>

Converts the object into a little-endian byte vector.
Source§

fn from_script(script: &[u8]) -> Self

Creates an instance from a script byte slice.
Source§

fn from_public_key(public_key: &[u8]) -> Result<Self, TypeError>

§

impl Serialize for H160

§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl UpperHex for H160

§

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

Formats the value using the given formatter. Read more
Source§

impl ValueExtension for H160

Source§

fn to_value(&self) -> Value

§

impl Copy for H160

§

impl Eq for H160

Auto Trait Implementations§

§

impl Freeze for H160

§

impl RefUnwindSafe for H160

§

impl Send for H160

§

impl Sync for H160

§

impl Unpin for H160

§

impl UnwindSafe for H160

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

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

§

impl<T, U> AsMutByteSlice<T> for U
where T: ToMutByteSlice, U: AsMut<[T]> + ?Sized,

§

fn as_mut_byte_slice(&mut self) -> &mut [u8]

§

impl<U> AsMutSliceOf for U
where U: AsMut<[u8]> + ?Sized,

§

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

§

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

§

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

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
Source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
§

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

§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

👎Deprecated: use ToHexExt instead
Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca).
§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

👎Deprecated: use ToHexExt instead
Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA).
§

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

§

fn encode_hex(&self) -> String

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca).
§

fn encode_hex_upper(&self) -> String

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA).
§

fn encode_hex_with_prefix(&self) -> String

Encode the hex strict representing self into the result with prefix 0x. Lower case letters are used (e.g. 0xf9b4ca).
§

fn encode_hex_upper_with_prefix(&self) -> String

Encode the hex strict representing self into the result with prefix 0X. Upper case letters are used (e.g. 0xF9B4CA).
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

§

impl<T> ErasedDestructor for T
where T: 'static,