Pubkey

Struct Pubkey 

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

The address of a Solana account.

Some account addresses are ed25519 public keys, with corresponding secret keys that are managed off-chain. Often, though, account addresses do not have corresponding secret keys — as with program derived addresses — or the secret key is not relevant to the operation of a program, and may have even been disposed of. As running Solana programs can not safely create or manage secret keys, the full Keypair is not defined in solana-program but in solana-sdk.

Implementations§

Source§

impl Pubkey

Source

pub const fn new_from_array(pubkey_array: [u8; 32]) -> Pubkey

Source

pub const fn from_str_const(s: &str) -> Pubkey

Decode a string into a Pubkey, usable in a const context

Source

pub fn new_unique() -> Pubkey

unique Pubkey for tests and benchmarks.

Source

pub const fn to_bytes(self) -> [u8; 32]

Source

pub const fn as_array(&self) -> &[u8; 32]

Return a reference to the Pubkey’s byte array.

Source

pub fn log(&self)

Log a Pubkey from a program

Trait Implementations§

Source§

impl AsMut<[u8]> for Pubkey

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for Pubkey

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Pubkey

Source§

fn clone(&self) -> Pubkey

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 Pubkey

Source§

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

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

impl Default for Pubkey

Source§

fn default() -> Pubkey

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Pubkey

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Pubkey, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

impl Display for Pubkey

Source§

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

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

impl From<&Pubkey> for Pubkey

Source§

fn from(value: &Pubkey) -> Pubkey

Converts to this type from the input type.
Source§

impl From<[u8; 32]> for Pubkey

Source§

fn from(from: [u8; 32]) -> Pubkey

Converts to this type from the input type.
Source§

impl FromStr for Pubkey

Source§

type Err = ParsePubkeyError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Pubkey, <Pubkey as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Pubkey

Custom impl of Hash for Pubkey allows us to skip hashing the length of the pubkey which is always the same anyway

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 Ord for Pubkey

Source§

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

Source§

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

Source§

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

Source§

impl Serialize for Pubkey

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 TryFrom<&[u8]> for Pubkey

Source§

type Error = TryFromSliceError

The type returned in the event of a conversion error.
Source§

fn try_from(pubkey: &[u8]) -> Result<Pubkey, <Pubkey as TryFrom<&[u8]>>::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for Pubkey

Source§

type Error = ParsePubkeyError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &str) -> Result<Pubkey, <Pubkey as TryFrom<&str>>::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for Pubkey

Source§

type Error = Vec<u8>

The type returned in the event of a conversion error.
Source§

fn try_from( pubkey: Vec<u8>, ) -> Result<Pubkey, <Pubkey as TryFrom<Vec<u8>>>::Error>

Performs the conversion.
Source§

impl Zeroable for Pubkey

Source§

fn zeroed() -> Self

Source§

impl Copy for Pubkey

Source§

impl Eq for Pubkey

Source§

impl Pod for Pubkey

Source§

impl StructuralPartialEq for Pubkey

Auto Trait Implementations§

§

impl Freeze for Pubkey

§

impl RefUnwindSafe for Pubkey

§

impl Send for Pubkey

§

impl Sync for Pubkey

§

impl Unpin for Pubkey

§

impl UnwindSafe for Pubkey

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<T> AnyBitPattern for T
where T: Pod,

Source§

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

Source§

impl<T> NoUninit for T
where T: Pod,