Struct ShortHrp

Source
pub struct ShortHrp(/* private fields */);
Expand description

Short human-readable address part

Implementations§

Source§

impl ShortHrp

Source

pub const MAX_HRP_LENGTH: usize = 5usize

Maximum length of the human-readable part of the address

Source

pub const MAINNET: Self

Mainnet human-readable part

Source

pub const TESTNET: Self

Testnet human-readable part

Source

pub fn new(hrp: Hrp) -> Option<Self>

Create a new instance.

Returns None if length of human-readable part is longer than Self::MAX_HRP_LENGTH.

Methods from Deref<Target = Hrp>§

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

Returns this human-readable part as bytes.

pub fn as_str(&self) -> &str

Returns this human-readable part as str.

pub fn byte_iter(&self) -> ByteIter<'_>

Creates a byte iterator over the ASCII byte values (ASCII characters) of this HRP.

If an uppercase HRP was parsed during object construction then this iterator will yield uppercase ASCII chars. For lowercase bytes see [Self::lowercase_byte_iter]

pub fn char_iter(&self) -> CharIter<'_>

Creates a character iterator over the ASCII characters of this HRP.

If an uppercase HRP was parsed during object construction then this iterator will yield uppercase ASCII chars. For lowercase bytes see [Self::lowercase_char_iter].

pub fn lowercase_byte_iter(&self) -> LowercaseByteIter<'_>

Creates a lowercase iterator over the byte values (ASCII characters) of this HRP.

pub fn lowercase_char_iter(&self) -> LowercaseCharIter<'_>

Creates a lowercase character iterator over the ASCII characters of this HRP.

pub fn len(&self) -> usize

Returns the length (number of characters) of the human-readable part.

Guaranteed to be between 1 and 83 inclusive.

pub fn is_valid_segwit(&self) -> bool

Returns true if this HRP is valid according to the bips.

BIP-173 states that the HRP must be either “bc” or “tb”.

pub fn is_valid_on_mainnet(&self) -> bool

Returns true if this HRP is valid on the Bitcoin network i.e., HRP is “bc”.

pub fn is_valid_on_testnet(&self) -> bool

Returns true if this HRP is valid on the Bitcoin testnet network i.e., HRP is “tb”.

pub fn is_valid_on_signet(&self) -> bool

Returns true if this HRP is valid on the Bitcoin signet network i.e., HRP is “tb”.

pub fn is_valid_on_regtest(&self) -> bool

Returns true if this HRP is valid on the Bitcoin regtest network i.e., HRP is “bcrt”.

Trait Implementations§

Source§

impl Clone for ShortHrp

Source§

fn clone(&self) -> ShortHrp

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 Debug for ShortHrp

Source§

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

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

impl Deref for ShortHrp

Source§

type Target = Hrp

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl PartialEq for ShortHrp

Source§

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

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

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

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

impl Copy for ShortHrp

Source§

impl Eq for ShortHrp

Source§

impl StructuralPartialEq for ShortHrp

Auto Trait Implementations§

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
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> 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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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<T> JsonSchemaMaybe for T