pub struct Address(/* private fields */);Expand description
A Solana address (public key): 32 bytes, transparent layout.
This is part of the Hopper runtime type surface.
PartialEq/Eq are implemented manually (see below) so every
Address == Address in the runtime and in user programs compiles
to the 4 x u64 word compare in address_eq rather than a
bytewise loop. PartialOrd/Ord stay derived: word-equality and
byte-equality decide the same pairs equal, so the derived ordering
remains consistent with the manual equality.
Implementations§
Source§impl Address
impl Address
Sourcepub const fn new_from_array(bytes: [u8; 32]) -> Self
pub const fn new_from_array(bytes: [u8; 32]) -> Self
Construct from a raw byte array (alias for compatibility).
Source§impl Address
impl Address
Sourcepub fn as_upstream<T>(&self) -> &Twhere
T: TransparentAddress,
pub fn as_upstream<T>(&self) -> &Twhere
T: TransparentAddress,
Zero-cost borrow as a reference to any #[repr(transparent)]
32-byte type that shares layout with [u8; 32].
This is the preferred way to pass a Hopper Address where an
upstream reference is expected.
§Safety
Safe because Address is #[repr(transparent)] over [u8; 32]
and any upstream 32-byte address type shares this layout.
Sourcepub fn from_upstream<T>(upstream: &T) -> &Addresswhere
T: TransparentAddress,
pub fn from_upstream<T>(upstream: &T) -> &Addresswhere
T: TransparentAddress,
Construct a Hopper Address reference from any #[repr(transparent)]
32-byte address type.
Trait Implementations§
impl Copy for Address
impl Eq for Address
Source§impl ExternalLensValue for Address
impl ExternalLensValue for Address
Source§impl Ord for Address
impl Ord for Address
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Address
impl PartialOrd for Address
impl Pod for Address
Source§impl SeqElement for Address
impl SeqElement for Address
Source§impl TailCodec for Address
impl TailCodec for Address
Source§const MAX_ENCODED_LEN: usize = 32
const MAX_ENCODED_LEN: usize = 32
encode.
Implementors should pick the smallest valid bound. Hopper
uses this to pre-size reallocs.