Struct nostr_sdk::bitcoin::CompactTarget
pub struct CompactTarget(/* private fields */);
Expand description
Encoding of 256-bit target as 32-bit float.
This is used to encode a target into the block header. Satoshi made this part of consensus code in the original version of Bitcoin, likely copying an idea from OpenSSL.
OpenSSL’s bignum (BN) type has an encoding, which is even called “compact” as in bitcoin, which is exactly this format.
Implementations§
§impl CompactTarget
impl CompactTarget
pub fn from_consensus(bits: u32) -> CompactTarget
pub fn from_consensus(bits: u32) -> CompactTarget
Creates a CompactTarget
from a consensus encoded u32
.
pub fn to_consensus(self) -> u32
pub fn to_consensus(self) -> u32
Returns the consensus encoded u32
representation of this CompactTarget
.
Trait Implementations§
§impl Clone for CompactTarget
impl Clone for CompactTarget
§fn clone(&self) -> CompactTarget
fn clone(&self) -> CompactTarget
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for CompactTarget
impl Debug for CompactTarget
§impl Decodable for CompactTarget
impl Decodable for CompactTarget
§impl Default for CompactTarget
impl Default for CompactTarget
§fn default() -> CompactTarget
fn default() -> CompactTarget
Returns the “default value” for a type. Read more
§impl<'de> Deserialize<'de> for CompactTarget
impl<'de> Deserialize<'de> for CompactTarget
§fn deserialize<__D>(
__deserializer: __D
) -> Result<CompactTarget, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<CompactTarget, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Encodable for CompactTarget
impl Encodable for CompactTarget
§impl From<CompactTarget> for Target
impl From<CompactTarget> for Target
§fn from(c: CompactTarget) -> Target
fn from(c: CompactTarget) -> Target
Converts to this type from the input type.
§impl FromHexStr for CompactTarget
impl FromHexStr for CompactTarget
§type Error = ParseIntError
type Error = ParseIntError
An error occurred while parsing the hex string.
§fn from_hex_str_no_prefix<S>(
s: S
) -> Result<CompactTarget, <CompactTarget as FromHexStr>::Error>where
S: AsRef<str> + Into<String>,
fn from_hex_str_no_prefix<S>( s: S ) -> Result<CompactTarget, <CompactTarget as FromHexStr>::Error>where S: AsRef<str> + Into<String>,
Parses provided string as hex without requiring 0x prefix. Read more
§fn from_hex_str<S>(s: S) -> Result<Self, FromHexError<Self::Error>>where
S: AsRef<str> + Into<String>,
fn from_hex_str<S>(s: S) -> Result<Self, FromHexError<Self::Error>>where S: AsRef<str> + Into<String>,
Parses provided string as hex requiring 0x prefix. Read more
§impl Hash for CompactTarget
impl Hash for CompactTarget
§impl Ord for CompactTarget
impl Ord for CompactTarget
§impl PartialEq<CompactTarget> for CompactTarget
impl PartialEq<CompactTarget> for CompactTarget
§fn eq(&self, other: &CompactTarget) -> bool
fn eq(&self, other: &CompactTarget) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.§impl PartialOrd<CompactTarget> for CompactTarget
impl PartialOrd<CompactTarget> for CompactTarget
§fn partial_cmp(&self, other: &CompactTarget) -> Option<Ordering>
fn partial_cmp(&self, other: &CompactTarget) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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§impl Serialize for CompactTarget
impl Serialize for CompactTarget
§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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 Copy for CompactTarget
impl Eq for CompactTarget
impl StructuralEq for CompactTarget
impl StructuralPartialEq for CompactTarget
Auto Trait Implementations§
impl RefUnwindSafe for CompactTarget
impl Send for CompactTarget
impl Sync for CompactTarget
impl Unpin for CompactTarget
impl UnwindSafe for CompactTarget
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.