pub enum Address {
Base(BaseAddress),
Ptr(PointerAddress),
Enterprise(EnterpriseAddress),
Reward(RewardAddress),
Byron(ByronAddress),
}Variants§
Base(BaseAddress)
Ptr(PointerAddress)
Enterprise(EnterpriseAddress)
Reward(RewardAddress)
Byron(ByronAddress)
Implementations§
Source§impl Address
impl Address
Sourcepub fn header(&self) -> u8
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)
pub fn header_matches_kind(header: u8, kind: AddressHeaderKind) -> bool
pub fn to_hex(&self) -> String
pub fn from_hex(hex: &str) -> Result<Address, DeserializeError>
Sourcepub fn to_raw_bytes(&self) -> Vec<u8> ⓘ
pub fn to_raw_bytes(&self) -> Vec<u8> ⓘ
The raw bytes of the Address - does not include any wrapping CBOR
pub fn from_raw_bytes(data: &[u8]) -> Result<Address, DeserializeError>
pub fn to_bech32(&self, prefix: Option<String>) -> Result<String, AddressError>
pub fn from_bech32(bech_str: &str) -> Result<Address, AddressError>
Sourcepub fn is_valid_bech32(bech_str: &str) -> bool
pub fn is_valid_bech32(bech_str: &str) -> bool
Note: bech32-encoded Byron addresses will also pass validation here
pub fn is_valid_byron(base58: &str) -> bool
pub fn is_valid(bech_str: &str) -> bool
pub fn kind(&self) -> AddressKind
pub fn network_id(&self) -> Result<u8, AddressError>
Sourcepub fn payment_cred(&self) -> Option<&Credential>
pub fn payment_cred(&self) -> Option<&Credential>
Note: by convention, the key inside reward addresses are considered payment credentials
Sourcepub fn staking_cred(&self) -> Option<&Credential>
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<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Address, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Address, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Deserialize for Address
impl Deserialize for Address
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,
fn from_cbor_bytes(data: &[u8]) -> Result<Self, DeserializeError>where
Self: Sized,
Source§impl From<BaseAddress> for Address
impl From<BaseAddress> for Address
Source§fn from(enterprise: BaseAddress) -> Address
fn from(enterprise: BaseAddress) -> Address
Source§impl From<ByronAddress> for Address
impl From<ByronAddress> for Address
Source§fn from(byron: ByronAddress) -> Address
fn from(byron: ByronAddress) -> Address
Source§impl From<EnterpriseAddress> for Address
impl From<EnterpriseAddress> for Address
Source§fn from(enterprise: EnterpriseAddress) -> Address
fn from(enterprise: EnterpriseAddress) -> Address
Source§impl From<PointerAddress> for Address
impl From<PointerAddress> for Address
Source§fn from(pointer: PointerAddress) -> Address
fn from(pointer: PointerAddress) -> Address
Source§impl From<RewardAddress> for Address
impl From<RewardAddress> for Address
Source§fn from(reward: RewardAddress) -> Address
fn from(reward: RewardAddress) -> Address
Source§impl JsonSchema for Address
impl JsonSchema for Address
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl Ord for Address
impl Ord for Address
Source§impl PartialOrd for Address
impl PartialOrd for Address
Source§impl Serialize for Address
impl Serialize for Address
Source§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,
Source§impl Serialize for Address
impl Serialize for Address
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> ⓘ
fn to_cbor_bytes(&self) -> Vec<u8> ⓘ
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromBytes for Twhere
T: Deserialize,
impl<T> FromBytes for Twhere
T: Deserialize,
fn from_bytes(data: Vec<u8>) -> Result<T, DeserializeError>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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