pub struct Sha256dHash(pub [u8; 32]);
Expand description

A Bitcoin hash, 32-bytes, computed from x as SHA256(SHA256(x))

Tuple Fields§

§0: [u8; 32]

Implementations§

source§

impl Sha256dHash

source

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

Converts the object to a raw pointer

source

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

Converts the object to a mutable raw pointer

source

pub fn len(&self) -> usize

Returns the length of the object as an array

source

pub fn is_empty(&self) -> bool

Returns whether the object, as an array, is empty. Always false.

source

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

Returns the underlying bytes.

source

pub fn to_bytes(&self) -> [u8; 32]

Returns the underlying bytes.

source

pub fn into_bytes(self) -> [u8; 32]

Returns the underlying bytes.

source§

impl Sha256dHash

source

pub fn from_data(data: &[u8]) -> Sha256dHash

Create a hash by hashing some data

source

pub fn into_le(self) -> Uint256

Converts a hash to a little-endian Uint256

source

pub fn into_be(self) -> Uint256

Converts a hash to a big-endian Uint256

source

pub fn from_hex(s: &str) -> Result<Sha256dHash, HexError>

Decodes a big-endian (i.e. reversed vs sha256sum output) hex string as a Sha256dHash

source

pub fn from_hex_le(s: &str) -> Result<Sha256dHash, HexError>

Decodes a little-endian (i.e. same as sha256sum output) hex string as a Sha256dHash

source

pub fn le_hex_string(&self) -> String

Human-readable hex output

source

pub fn be_hex_string(&self) -> String

Human-readable hex output

Trait Implementations§

source§

impl Clone for Sha256dHash

source§

fn clone(&self) -> Sha256dHash

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<D: SimpleDecoder> ConsensusDecodable<D> for Sha256dHash

source§

fn consensus_decode(d: &mut D) -> Result<Sha256dHash, Error>

Decode an object with a well-defined format
source§

impl<S: SimpleEncoder> ConsensusEncodable<S> for Sha256dHash

source§

fn consensus_encode(&self, s: &mut S) -> Result<(), Error>

Encode an object with a well-defined format
source§

impl Debug for Sha256dHash

source§

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

Output the raw sha256d hash, not reversing it (unlike Display and what Core does for user display)

source§

impl Default for Sha256dHash

source§

fn default() -> Sha256dHash

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

impl Display for Sha256dHash

source§

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

Output the sha256d hash in reverse, copying Bitcoin Core’s behaviour

source§

impl<'a> From<&'a [u8]> for Sha256dHash

source§

fn from(data: &'a [u8]) -> Sha256dHash

Converts to this type from the input type.
source§

impl FromSql for Sha256dHash

source§

fn column_result(value: ValueRef<'_>) -> FromSqlResult<Sha256dHash>

Converts SQLite value into Rust value.
source§

impl Hash for Sha256dHash

source§

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

Feeds this value into the given Hasher. Read more
source§

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

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

impl Index<Range<usize>> for Sha256dHash

§

type Output = [u8]

The returned type after indexing.
source§

fn index(&self, index: Range<usize>) -> &[u8]

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

impl Index<RangeFrom<usize>> for Sha256dHash

§

type Output = [u8]

The returned type after indexing.
source§

fn index(&self, index: RangeFrom<usize>) -> &[u8]

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

impl Index<RangeFull> for Sha256dHash

§

type Output = [u8]

The returned type after indexing.
source§

fn index(&self, _: RangeFull) -> &[u8]

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

impl Index<RangeTo<usize>> for Sha256dHash

§

type Output = [u8]

The returned type after indexing.
source§

fn index(&self, index: RangeTo<usize>) -> &[u8]

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

impl Index<usize> for Sha256dHash

§

type Output = u8

The returned type after indexing.
source§

fn index(&self, index: usize) -> &u8

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

impl LowerHex for Sha256dHash

source§

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

Output the sha256d hash in reverse, copying Bitcoin Core’s behaviour

source§

impl Ord for Sha256dHash

source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Sha256dHash> for Sha256dHash

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl PartialOrd<Sha256dHash> for Sha256dHash

source§

fn partial_cmp(&self, other: &Sha256dHash) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ToSql for Sha256dHash

source§

fn to_sql(&self) -> Result<ToSqlOutput<'_>>

Converts Rust value to SQLite value
source§

impl UpperHex for Sha256dHash

source§

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

Output the sha256d hash in reverse, copying Bitcoin Core’s behaviour

source§

impl Copy for Sha256dHash

source§

impl Eq for Sha256dHash

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

§

impl<T> Clear for Twhere T: InitializableFromZeroed + ?Sized,

§

fn clear(&mut self)

Completely overwrites this value.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InitializableFromZeroed for Twhere T: Default,

§

unsafe fn initialize(place: *mut T)

Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more
source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> SendSyncUnwindSafe for Twhere T: Send + Sync + UnwindSafe + ?Sized,