Address

Enum Address 

Source
pub enum Address {
    Base(BaseAddress),
    Ptr(PointerAddress),
    Enterprise(EnterpriseAddress),
    Reward(RewardAddress),
    Byron(ByronAddress),
}

Variants§

Implementations§

Source§

impl Address

Source

pub fn header(&self) -> u8

header has 4 bits addr type discrim then 4 bits network discrim. Copied from shelley.cddl:

base address bits 7-6: 00 bit 5: stake cred is keyhash/scripthash bit 4: payment cred is keyhash/scripthash bits 3-0: network id

pointer address bits 7-5: 010 bit 4: payment cred is keyhash/scripthash bits 3-0: network id

enterprise address bits 7-5: 010 bit 4: payment cred is keyhash/scripthash bits 3-0: network id

reward addresses: bits 7-5: 111 bit 4: credential is keyhash/scripthash bits 3-0: network id

byron addresses: bits 7-4: 1000 bits 3-0: unrelated data (recall: no network ID in Byron addresses)

Source

pub fn header_matches_kind(header: u8, kind: AddressHeaderKind) -> bool

Source

pub fn to_hex(&self) -> String

Source

pub fn from_hex(hex: &str) -> Result<Address, DeserializeError>

Source

pub fn to_raw_bytes(&self) -> Vec<u8>

The raw bytes of the Address - does not include any wrapping CBOR

Source

pub fn from_raw_bytes(data: &[u8]) -> Result<Address, DeserializeError>

Source

pub fn to_bech32(&self, prefix: Option<String>) -> Result<String, AddressError>

Source

pub fn from_bech32(bech_str: &str) -> Result<Address, AddressError>

Source

pub fn is_valid_bech32(bech_str: &str) -> bool

Note: bech32-encoded Byron addresses will also pass validation here

Source

pub fn is_valid_byron(base58: &str) -> bool

Source

pub fn is_valid(bech_str: &str) -> bool

Source

pub fn kind(&self) -> AddressKind

Source

pub fn network_id(&self) -> Result<u8, AddressError>

Source

pub fn payment_cred(&self) -> Option<&Credential>

Note: by convention, the key inside reward addresses are considered payment credentials

Source

pub fn staking_cred(&self) -> Option<&Credential>

Note: by convention, the key inside reward addresses are NOT considered staking credentials Note: None is returned pointer addresses as the chain history is required to resolve its associated cred

Trait Implementations§

Source§

impl Clone for Address

Source§

fn clone(&self) -> Address

Returns a duplicate 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 Address

Source§

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

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

impl<'de> Deserialize<'de> for Address

Source§

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

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

impl Deserialize for Address

Source§

fn deserialize<R>( raw: &mut Deserializer<R>, ) -> Result<Address, DeserializeError>
where R: BufRead,

Source§

fn from_cbor_bytes(data: &[u8]) -> Result<Self, DeserializeError>
where Self: Sized,

from-bytes using the exact CBOR format specified in the CDDL binary spec. For hashes/addresses/etc this will include the CBOR bytes type/len/etc.
Source§

impl From<BaseAddress> for Address

Source§

fn from(enterprise: BaseAddress) -> Address

Converts to this type from the input type.
Source§

impl From<ByronAddress> for Address

Source§

fn from(byron: ByronAddress) -> Address

Converts to this type from the input type.
Source§

impl From<EnterpriseAddress> for Address

Source§

fn from(enterprise: EnterpriseAddress) -> Address

Converts to this type from the input type.
Source§

impl From<PointerAddress> for Address

Source§

fn from(pointer: PointerAddress) -> Address

Converts to this type from the input type.
Source§

impl From<RewardAddress> for Address

Source§

fn from(reward: RewardAddress) -> Address

Converts to this type from the input type.
Source§

impl Hash for Address

Source§

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

impl JsonSchema for Address

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl Ord for Address

Source§

fn cmp(&self, other: &Address) -> 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
Source§

impl PartialEq for Address

Source§

fn eq(&self, other: &Address) -> 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 PartialOrd for Address

Source§

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

Source§

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

impl Serialize for Address

Source§

fn serialize<'se, W>( &self, serializer: &'se mut Serializer<W>, force_canonical: bool, ) -> Result<&'se mut Serializer<W>, Error>
where W: Write,

Source§

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

Bytes of a structure using the CBOR bytes as per the CDDL spec which for foo = bytes will include the CBOR bytes type/len, etc. This gives the original bytes in the case where this was created from bytes originally, or will use whatever the specific encoding details are present in any encoding details struct for the type.
Source§

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

Bytes of a structure using the CBOR bytes as per the CDDL spec which for foo = bytes will include the CBOR bytes type/len, etc. This gives the canonically encoded CBOR bytes always
Source§

impl Eq for Address

Source§

impl StructuralPartialEq for Address

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromBytes for T
where T: Deserialize,

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

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

Source§

fn vzip(self) -> V

Source§

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