pub struct TypedAddress<T> { /* private fields */ }Expand description
A 32-byte public key tagged with a phantom layout type.
Zero-cost: #[repr(transparent)] over [u8; 32], align 1.
The type parameter T exists only at compile time for type safety –
it has no runtime representation.
Implementations§
Source§impl<T> TypedAddress<T>
impl<T> TypedAddress<T>
Sourcepub const fn new(bytes: [u8; 32]) -> TypedAddress<T>
pub const fn new(bytes: [u8; 32]) -> TypedAddress<T>
Create a typed address from raw bytes.
Sourcepub fn from_slice(slice: &[u8; 32]) -> TypedAddress<T>
pub fn from_slice(slice: &[u8; 32]) -> TypedAddress<T>
Create from a byte slice reference (copies 32 bytes).
Sourcepub fn from_account(account: &AccountView) -> TypedAddress<T>
pub fn from_account(account: &AccountView) -> TypedAddress<T>
Create from an AccountView’s address.
Sourcepub const fn zeroed() -> TypedAddress<T>
pub const fn zeroed() -> TypedAddress<T>
The zero address (all bytes 0).
Sourcepub fn eq_bytes(&self, other: &[u8; 32]) -> bool
pub fn eq_bytes(&self, other: &[u8; 32]) -> bool
Check if this address equals a raw 32-byte key.
Sourcepub fn eq_account(&self, account: &AccountView) -> bool
pub fn eq_account(&self, account: &AccountView) -> bool
Check if this address matches an AccountView’s address.
Sourcepub fn require_eq_account(
&self,
account: &AccountView,
) -> Result<(), ProgramError>
pub fn require_eq_account( &self, account: &AccountView, ) -> Result<(), ProgramError>
Verify this address matches the given account, returning an error if not.
Sourcepub const fn cast<U>(self) -> TypedAddress<U>
pub const fn cast<U>(self) -> TypedAddress<U>
Cast this typed address to a different type.
Use sparingly – this exists for interop with legacy/untyped code.
Sourcepub const fn untyped(self) -> UntypedAddress
pub const fn untyped(self) -> UntypedAddress
Erase the type tag, returning an untyped address.
Trait Implementations§
Source§impl<T> AsRef<[u8]> for TypedAddress<T>
impl<T> AsRef<[u8]> for TypedAddress<T>
Source§impl<T> Clone for TypedAddress<T>
impl<T> Clone for TypedAddress<T>
Source§fn clone(&self) -> TypedAddress<T>
fn clone(&self) -> TypedAddress<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for TypedAddress<T>
impl<T> Debug for TypedAddress<T>
Source§impl<T> FixedLayout for TypedAddress<T>
impl<T> FixedLayout for TypedAddress<T>
Source§impl<T> PartialEq for TypedAddress<T>
impl<T> PartialEq for TypedAddress<T>
Source§fn eq(&self, other: &TypedAddress<T>) -> bool
fn eq(&self, other: &TypedAddress<T>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<T> Zeroable for TypedAddress<T>where
T: 'static,
Available on crate feature hopper-native-backend only.
impl<T> Zeroable for TypedAddress<T>where
T: 'static,
Available on crate feature
hopper-native-backend only.impl<T> Copy for TypedAddress<T>
impl<T> Eq for TypedAddress<T>
impl<T> Pod for TypedAddress<T>where
T: Copy + 'static,
Available on crate feature
hopper-native-backend only.impl<T> Pod for TypedAddress<T>where
T: Copy + 'static,
Auto Trait Implementations§
impl<T> Freeze for TypedAddress<T>
impl<T> RefUnwindSafe for TypedAddress<T>where
T: RefUnwindSafe,
impl<T> Send for TypedAddress<T>where
T: Send,
impl<T> Sync for TypedAddress<T>where
T: Sync,
impl<T> Unpin for TypedAddress<T>where
T: Unpin,
impl<T> UnsafeUnpin for TypedAddress<T>
impl<T> UnwindSafe for TypedAddress<T>where
T: UnwindSafe,
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<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self.