pub struct H160(pub [u8; 20]);
Expand description
Fixed hash type.
Tuple Fields§
§0: [u8; 20]
Implementations§
Source§impl H160
impl H160
Sourcepub const fn repeat_byte(byte: u8) -> Self
pub const fn repeat_byte(byte: u8) -> Self
Return a new fixed hash where all bytes are set to the given byte.
Sourcepub const fn zero() -> Self
👎Deprecated since 0.1.5: Please use the empty function instead
pub const fn zero() -> Self
Create a new fixed hash and all bits of it are zeros.
Sourcepub fn is_zero(&self) -> bool
👎Deprecated since 0.1.5: Please use the is_empty function instead
pub fn is_zero(&self) -> bool
Test if all bits of a fixed hash are zero.
Sourcepub fn is_max(&self) -> bool
👎Deprecated since 0.1.5: Please use the is_full function instead
pub fn is_max(&self) -> bool
Test if all bits of a fixed hash are one.
Sourcepub const fn count_bits() -> u64
pub const fn count_bits() -> u64
Return the count of bits.
Sourcepub fn bit(&self, index: usize) -> Option<bool>
pub fn bit(&self, index: usize) -> Option<bool>
Return a specific bit, or return None when overlows.
Order from low to high.
Sourcepub fn set_bit(&mut self, index: usize, value: bool) -> bool
pub fn set_bit(&mut self, index: usize, value: bool) -> bool
Set a specific bit. Return false when overflows.
Order from low to high.
Sourcepub fn highest_one(&self) -> Option<usize>
pub fn highest_one(&self) -> Option<usize>
Return the highest bit which is one.
Order from low to high.
Sourcepub fn lowest_one(&self) -> Option<usize>
pub fn lowest_one(&self) -> Option<usize>
Return the lowest bit which is one.
Order from low to high.
Sourcepub const fn count_bytes() -> u64
pub const fn count_bytes() -> u64
Return the count of bytes.
Sourcepub fn byte(&self, index: usize) -> Option<u8>
pub fn byte(&self, index: usize) -> Option<u8>
Return a specific byte, or return None when overlows.
Sourcepub fn set_byte(&mut self, index: usize, byte: u8) -> bool
pub fn set_byte(&mut self, index: usize, byte: u8) -> bool
Set a specific byte. Return false when overflows;
Sourcepub fn highest_nonzero_byte(&self) -> Option<usize>
pub fn highest_nonzero_byte(&self) -> Option<usize>
Return the highest byte which is nonzero.
Sourcepub fn lowest_nonzero_byte(&self) -> Option<usize>
pub fn lowest_nonzero_byte(&self) -> Option<usize>
Return the lowest byte which is nonzero.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Get the mutable inner bytes slice of a fixed hash.
Sourcepub fn as_fixed_bytes(&self) -> &[u8; 20]
pub fn as_fixed_bytes(&self) -> &[u8; 20]
Get the inner bytes of a fixed hash.
Sourcepub fn as_fixed_bytes_mut(&mut self) -> &mut [u8; 20]
pub fn as_fixed_bytes_mut(&mut self) -> &mut [u8; 20]
Get the mutable inner bytes of a fixed hash.
Sourcepub fn into_fixed_bytes(self) -> [u8; 20]
pub fn into_fixed_bytes(self) -> [u8; 20]
Get the inner bytes array of a fixed hash.
Sourcepub fn as_ptr(&self) -> *const u8
pub fn as_ptr(&self) -> *const u8
Get a constant raw pointer to the inner bytes array of a fixed hash.
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Get a mutable raw pointer to the inner bytes array of a fixed hash.
Sourcepub const fn size_of() -> usize
pub const fn size_of() -> usize
Return the size used by this type in bytes, actually.
This size is greater than or equal to the bytes of this fixed type.
Sourcepub fn from_slice(input: &[u8]) -> Result<Self, FixedHashError>
pub fn from_slice(input: &[u8]) -> Result<Self, FixedHashError>
Convert from slice.
Sourcepub fn into_slice(&self, output: &mut [u8]) -> Result<(), FixedHashError>
pub fn into_slice(&self, output: &mut [u8]) -> Result<(), FixedHashError>
Convert into slice.
Sourcepub fn from_hex_str(input: &str) -> Result<Self, FixedHashError>
pub fn from_hex_str(input: &str) -> Result<Self, FixedHashError>
Convert from a fixed length hexadecimal string.
Sourcepub fn from_trimmed_hex_str(input: &str) -> Result<Self, FixedHashError>
pub fn from_trimmed_hex_str(input: &str) -> Result<Self, FixedHashError>
Convert from an arbitrary length zero-trimmed hexadecimal string. Fisrt char should not be zero if the input has more than one char.
Sourcepub const fn min_value() -> Self
pub const fn min_value() -> Self
Returns the smallest value that can be represented by this integer type.
Sourcepub const fn max_value() -> Self
pub const fn max_value() -> Self
Returns the largest value that can be represented by this integer type.
Sourcepub fn count_ones(&self) -> u32
pub fn count_ones(&self) -> u32
Returns the number of ones in the binary representation of self.
Sourcepub fn count_zeros(&self) -> u32
pub fn count_zeros(&self) -> u32
Returns the number of zeros in the binary representation of self.
Sourcepub fn leading_zeros(&self) -> u32
pub fn leading_zeros(&self) -> u32
Returns the number of leading zeros in the binary representation of self.
Sourcepub fn trailing_zeros(&self) -> u32
pub fn trailing_zeros(&self) -> u32
Returns the number of trailing zeros in the binary representation of self.
Sourcepub fn checked_shl(&self, rhs: u128) -> Option<Self>
pub fn checked_shl(&self, rhs: u128) -> Option<Self>
Checked shift left. Computes self << rhs
,
returning None
if rhs
is larger than or equal to the number of bits in self
.
Sourcepub fn checked_shr(&self, rhs: u128) -> Option<Self>
pub fn checked_shr(&self, rhs: u128) -> Option<Self>
Checked shift right. Computes self >> rhs
,
returning None
if rhs
is larger than or equal to the number of bits in self
.
Sourcepub fn overflowing_shl(&self, rhs: u128) -> (Self, bool)
pub fn overflowing_shl(&self, rhs: u128) -> (Self, bool)
Shifts self
left by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating
whether the shift value was larger than or equal to the number of bits.
If the shift value is too large, then value is masked (N-1) where N is the number
of bits, and this value is then used to perform the shift.
Sourcepub fn overflowing_shr(&self, rhs: u128) -> (Self, bool)
pub fn overflowing_shr(&self, rhs: u128) -> (Self, bool)
Shifts self
right by rhs
bits.
Returns a tuple of the shifted version of self
along with a boolean indicating
whether the shift value was larger than or equal to the number of bits.
If the shift value is too large, then value is masked (N-1) where N is the number
of bits, and this value is then used to perform the shift.
Trait Implementations§
Source§impl<'a> BitAndAssign<&'a H160> for H160
impl<'a> BitAndAssign<&'a H160> for H160
Source§fn bitand_assign(&mut self, other: &H160)
fn bitand_assign(&mut self, other: &H160)
&=
operation. Read moreSource§impl<Rhs> BitAndAssign<Rhs> for H160
impl<Rhs> BitAndAssign<Rhs> for H160
Source§fn bitand_assign(&mut self, other: Rhs)
fn bitand_assign(&mut self, other: Rhs)
&=
operation. Read moreSource§impl<'a> BitOrAssign<&'a H160> for H160
impl<'a> BitOrAssign<&'a H160> for H160
Source§fn bitor_assign(&mut self, other: &H160)
fn bitor_assign(&mut self, other: &H160)
|=
operation. Read moreSource§impl<Rhs> BitOrAssign<Rhs> for H160
impl<Rhs> BitOrAssign<Rhs> for H160
Source§fn bitor_assign(&mut self, other: Rhs)
fn bitor_assign(&mut self, other: Rhs)
|=
operation. Read moreSource§impl<'a> BitXorAssign<&'a H160> for H160
impl<'a> BitXorAssign<&'a H160> for H160
Source§fn bitxor_assign(&mut self, other: &H160)
fn bitxor_assign(&mut self, other: &H160)
^=
operation. Read moreSource§impl<Rhs> BitXorAssign<Rhs> for H160
impl<Rhs> BitXorAssign<Rhs> for H160
Source§fn bitxor_assign(&mut self, other: Rhs)
fn bitxor_assign(&mut self, other: Rhs)
^=
operation. Read moreSource§impl HashConvert<H1024> for H160
impl HashConvert<H1024> for H160
Source§fn convert_into(&self) -> (H1024, bool)
fn convert_into(&self) -> (H1024, bool)
Source§impl HashConvert<H128> for H160
impl HashConvert<H128> for H160
Source§fn convert_into(&self) -> (H128, bool)
fn convert_into(&self) -> (H128, bool)
Source§impl HashConvert<H160> for H1024
impl HashConvert<H160> for H1024
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H128
impl HashConvert<H160> for H128
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H2048
impl HashConvert<H160> for H2048
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H224
impl HashConvert<H160> for H224
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H256
impl HashConvert<H160> for H256
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H384
impl HashConvert<H160> for H384
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H4096
impl HashConvert<H160> for H4096
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H512
impl HashConvert<H160> for H512
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H160> for H520
impl HashConvert<H160> for H520
Source§fn convert_into(&self) -> (H160, bool)
fn convert_into(&self) -> (H160, bool)
Source§impl HashConvert<H2048> for H160
impl HashConvert<H2048> for H160
Source§fn convert_into(&self) -> (H2048, bool)
fn convert_into(&self) -> (H2048, bool)
Source§impl HashConvert<H224> for H160
impl HashConvert<H224> for H160
Source§fn convert_into(&self) -> (H224, bool)
fn convert_into(&self) -> (H224, bool)
Source§impl HashConvert<H256> for H160
impl HashConvert<H256> for H160
Source§fn convert_into(&self) -> (H256, bool)
fn convert_into(&self) -> (H256, bool)
Source§impl HashConvert<H384> for H160
impl HashConvert<H384> for H160
Source§fn convert_into(&self) -> (H384, bool)
fn convert_into(&self) -> (H384, bool)
Source§impl HashConvert<H4096> for H160
impl HashConvert<H4096> for H160
Source§fn convert_into(&self) -> (H4096, bool)
fn convert_into(&self) -> (H4096, bool)
Source§impl HashConvert<H512> for H160
impl HashConvert<H512> for H160
Source§fn convert_into(&self) -> (H512, bool)
fn convert_into(&self) -> (H512, bool)
Source§impl HashConvert<H520> for H160
impl HashConvert<H520> for H160
Source§fn convert_into(&self) -> (H520, bool)
fn convert_into(&self) -> (H520, bool)
Source§impl Ord for H160
impl Ord for H160
Source§impl PartialOrd for H160
impl PartialOrd for H160
Source§impl<'a> ShlAssign<&'a i128> for H160
impl<'a> ShlAssign<&'a i128> for H160
Source§fn shl_assign(&mut self, other: &i128)
fn shl_assign(&mut self, other: &i128)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a i16> for H160
impl<'a> ShlAssign<&'a i16> for H160
Source§fn shl_assign(&mut self, other: &i16)
fn shl_assign(&mut self, other: &i16)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a i32> for H160
impl<'a> ShlAssign<&'a i32> for H160
Source§fn shl_assign(&mut self, other: &i32)
fn shl_assign(&mut self, other: &i32)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a i64> for H160
impl<'a> ShlAssign<&'a i64> for H160
Source§fn shl_assign(&mut self, other: &i64)
fn shl_assign(&mut self, other: &i64)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a i8> for H160
impl<'a> ShlAssign<&'a i8> for H160
Source§fn shl_assign(&mut self, other: &i8)
fn shl_assign(&mut self, other: &i8)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a isize> for H160
impl<'a> ShlAssign<&'a isize> for H160
Source§fn shl_assign(&mut self, other: &isize)
fn shl_assign(&mut self, other: &isize)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a u128> for H160
impl<'a> ShlAssign<&'a u128> for H160
Source§fn shl_assign(&mut self, other: &u128)
fn shl_assign(&mut self, other: &u128)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a u16> for H160
impl<'a> ShlAssign<&'a u16> for H160
Source§fn shl_assign(&mut self, other: &u16)
fn shl_assign(&mut self, other: &u16)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a u32> for H160
impl<'a> ShlAssign<&'a u32> for H160
Source§fn shl_assign(&mut self, other: &u32)
fn shl_assign(&mut self, other: &u32)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a u64> for H160
impl<'a> ShlAssign<&'a u64> for H160
Source§fn shl_assign(&mut self, other: &u64)
fn shl_assign(&mut self, other: &u64)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a u8> for H160
impl<'a> ShlAssign<&'a u8> for H160
Source§fn shl_assign(&mut self, other: &u8)
fn shl_assign(&mut self, other: &u8)
<<=
operation. Read moreSource§impl<'a> ShlAssign<&'a usize> for H160
impl<'a> ShlAssign<&'a usize> for H160
Source§fn shl_assign(&mut self, other: &usize)
fn shl_assign(&mut self, other: &usize)
<<=
operation. Read moreSource§impl ShlAssign<i128> for H160
impl ShlAssign<i128> for H160
Source§fn shl_assign(&mut self, other: i128)
fn shl_assign(&mut self, other: i128)
<<=
operation. Read moreSource§impl ShlAssign<i16> for H160
impl ShlAssign<i16> for H160
Source§fn shl_assign(&mut self, other: i16)
fn shl_assign(&mut self, other: i16)
<<=
operation. Read moreSource§impl ShlAssign<i32> for H160
impl ShlAssign<i32> for H160
Source§fn shl_assign(&mut self, other: i32)
fn shl_assign(&mut self, other: i32)
<<=
operation. Read moreSource§impl ShlAssign<i64> for H160
impl ShlAssign<i64> for H160
Source§fn shl_assign(&mut self, other: i64)
fn shl_assign(&mut self, other: i64)
<<=
operation. Read moreSource§impl ShlAssign<i8> for H160
impl ShlAssign<i8> for H160
Source§fn shl_assign(&mut self, other: i8)
fn shl_assign(&mut self, other: i8)
<<=
operation. Read moreSource§impl ShlAssign<isize> for H160
impl ShlAssign<isize> for H160
Source§fn shl_assign(&mut self, other: isize)
fn shl_assign(&mut self, other: isize)
<<=
operation. Read moreSource§impl ShlAssign<u128> for H160
impl ShlAssign<u128> for H160
Source§fn shl_assign(&mut self, other: u128)
fn shl_assign(&mut self, other: u128)
<<=
operation. Read moreSource§impl ShlAssign<u16> for H160
impl ShlAssign<u16> for H160
Source§fn shl_assign(&mut self, other: u16)
fn shl_assign(&mut self, other: u16)
<<=
operation. Read moreSource§impl ShlAssign<u32> for H160
impl ShlAssign<u32> for H160
Source§fn shl_assign(&mut self, other: u32)
fn shl_assign(&mut self, other: u32)
<<=
operation. Read moreSource§impl ShlAssign<u64> for H160
impl ShlAssign<u64> for H160
Source§fn shl_assign(&mut self, other: u64)
fn shl_assign(&mut self, other: u64)
<<=
operation. Read moreSource§impl ShlAssign<u8> for H160
impl ShlAssign<u8> for H160
Source§fn shl_assign(&mut self, other: u8)
fn shl_assign(&mut self, other: u8)
<<=
operation. Read moreSource§impl ShlAssign<usize> for H160
impl ShlAssign<usize> for H160
Source§fn shl_assign(&mut self, other: usize)
fn shl_assign(&mut self, other: usize)
<<=
operation. Read moreSource§impl<'a> ShrAssign<&'a i128> for H160
impl<'a> ShrAssign<&'a i128> for H160
Source§fn shr_assign(&mut self, other: &i128)
fn shr_assign(&mut self, other: &i128)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a i16> for H160
impl<'a> ShrAssign<&'a i16> for H160
Source§fn shr_assign(&mut self, other: &i16)
fn shr_assign(&mut self, other: &i16)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a i32> for H160
impl<'a> ShrAssign<&'a i32> for H160
Source§fn shr_assign(&mut self, other: &i32)
fn shr_assign(&mut self, other: &i32)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a i64> for H160
impl<'a> ShrAssign<&'a i64> for H160
Source§fn shr_assign(&mut self, other: &i64)
fn shr_assign(&mut self, other: &i64)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a i8> for H160
impl<'a> ShrAssign<&'a i8> for H160
Source§fn shr_assign(&mut self, other: &i8)
fn shr_assign(&mut self, other: &i8)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a isize> for H160
impl<'a> ShrAssign<&'a isize> for H160
Source§fn shr_assign(&mut self, other: &isize)
fn shr_assign(&mut self, other: &isize)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a u128> for H160
impl<'a> ShrAssign<&'a u128> for H160
Source§fn shr_assign(&mut self, other: &u128)
fn shr_assign(&mut self, other: &u128)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a u16> for H160
impl<'a> ShrAssign<&'a u16> for H160
Source§fn shr_assign(&mut self, other: &u16)
fn shr_assign(&mut self, other: &u16)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a u32> for H160
impl<'a> ShrAssign<&'a u32> for H160
Source§fn shr_assign(&mut self, other: &u32)
fn shr_assign(&mut self, other: &u32)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a u64> for H160
impl<'a> ShrAssign<&'a u64> for H160
Source§fn shr_assign(&mut self, other: &u64)
fn shr_assign(&mut self, other: &u64)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a u8> for H160
impl<'a> ShrAssign<&'a u8> for H160
Source§fn shr_assign(&mut self, other: &u8)
fn shr_assign(&mut self, other: &u8)
>>=
operation. Read moreSource§impl<'a> ShrAssign<&'a usize> for H160
impl<'a> ShrAssign<&'a usize> for H160
Source§fn shr_assign(&mut self, other: &usize)
fn shr_assign(&mut self, other: &usize)
>>=
operation. Read moreSource§impl ShrAssign<i128> for H160
impl ShrAssign<i128> for H160
Source§fn shr_assign(&mut self, other: i128)
fn shr_assign(&mut self, other: i128)
>>=
operation. Read moreSource§impl ShrAssign<i16> for H160
impl ShrAssign<i16> for H160
Source§fn shr_assign(&mut self, other: i16)
fn shr_assign(&mut self, other: i16)
>>=
operation. Read moreSource§impl ShrAssign<i32> for H160
impl ShrAssign<i32> for H160
Source§fn shr_assign(&mut self, other: i32)
fn shr_assign(&mut self, other: i32)
>>=
operation. Read moreSource§impl ShrAssign<i64> for H160
impl ShrAssign<i64> for H160
Source§fn shr_assign(&mut self, other: i64)
fn shr_assign(&mut self, other: i64)
>>=
operation. Read moreSource§impl ShrAssign<i8> for H160
impl ShrAssign<i8> for H160
Source§fn shr_assign(&mut self, other: i8)
fn shr_assign(&mut self, other: i8)
>>=
operation. Read moreSource§impl ShrAssign<isize> for H160
impl ShrAssign<isize> for H160
Source§fn shr_assign(&mut self, other: isize)
fn shr_assign(&mut self, other: isize)
>>=
operation. Read moreSource§impl ShrAssign<u128> for H160
impl ShrAssign<u128> for H160
Source§fn shr_assign(&mut self, other: u128)
fn shr_assign(&mut self, other: u128)
>>=
operation. Read moreSource§impl ShrAssign<u16> for H160
impl ShrAssign<u16> for H160
Source§fn shr_assign(&mut self, other: u16)
fn shr_assign(&mut self, other: u16)
>>=
operation. Read moreSource§impl ShrAssign<u32> for H160
impl ShrAssign<u32> for H160
Source§fn shr_assign(&mut self, other: u32)
fn shr_assign(&mut self, other: u32)
>>=
operation. Read moreSource§impl ShrAssign<u64> for H160
impl ShrAssign<u64> for H160
Source§fn shr_assign(&mut self, other: u64)
fn shr_assign(&mut self, other: u64)
>>=
operation. Read moreSource§impl ShrAssign<u8> for H160
impl ShrAssign<u8> for H160
Source§fn shr_assign(&mut self, other: u8)
fn shr_assign(&mut self, other: u8)
>>=
operation. Read moreSource§impl ShrAssign<usize> for H160
impl ShrAssign<usize> for H160
Source§fn shr_assign(&mut self, other: usize)
fn shr_assign(&mut self, other: usize)
>>=
operation. Read more