Struct mpl_token_auth_rules::payload::Payload
source · #[repr(C)]pub struct Payload { /* private fields */ }
Expand description
A wrapper type for the payload hashmap.
Implementations§
source§impl Payload
impl Payload
sourcepub fn from<const N: usize>(arr: [(String, PayloadType); N]) -> Self
pub fn from<const N: usize>(arr: [(String, PayloadType); N]) -> Self
Create a Payload
from an array of key-value pairs, specified as
(PayloadKey, PayloadType)
tuples.
sourcepub fn insert(&mut self, key: String, value: PayloadType) -> Option<PayloadType>
pub fn insert(&mut self, key: String, value: PayloadType) -> Option<PayloadType>
Inserts a key-value pair into the Payload
. If the Payload
did not have this key
present, then None
is returned. If the Payload
did have this key present, the value
is updated, and the old value is returned. The key is not updated, though; this matters
for types that can be ==
without being identical. See std::collections::HashMap
documentation for more info.
sourcepub fn try_insert(&mut self, key: String, value: PayloadType) -> ProgramResult
pub fn try_insert(&mut self, key: String, value: PayloadType) -> ProgramResult
Tries to insert a key-value pair into a Payload
. If this key is already in the Payload
nothing is updated and an error is returned.
sourcepub fn get(&self, key: &String) -> Option<&PayloadType>
pub fn get(&self, key: &String) -> Option<&PayloadType>
Returns a reference to the value corresponding to the key.
sourcepub fn get_pubkey(&self, key: &String) -> Option<&Pubkey>
pub fn get_pubkey(&self, key: &String) -> Option<&Pubkey>
Get a reference to the Pubkey
associated with a key, if and only if the Payload
value
is the PayloadType::Pubkey
variant. Returns None
if the key is not present in the
Payload
or the value is a different PayloadType
variant.
sourcepub fn get_seeds(&self, key: &String) -> Option<&SeedsVec>
pub fn get_seeds(&self, key: &String) -> Option<&SeedsVec>
Get a reference to the SeedsVec
associated with a key, if and only if the Payload
value
is the PayloadType::Seeds
variant. Returns None
if the key is not present in the
Payload
or the value is a different PayloadType
variant.
sourcepub fn get_merkle_proof(&self, key: &String) -> Option<&ProofInfo>
pub fn get_merkle_proof(&self, key: &String) -> Option<&ProofInfo>
Get a reference to the ProofInfo
associated with a key, if and only if the Payload
value
is the PayloadType::MerkleProof
variant. Returns None
if the key is not present in the
Payload
or the value is a different PayloadType
variant.
sourcepub fn get_amount(&self, key: &String) -> Option<u64>
pub fn get_amount(&self, key: &String) -> Option<u64>
Get the u64
associated with a key, if and only if the Payload
value is the
PayloadType::Number
variant. Returns None
if the key is not present in the Payload
or the value is a different PayloadType
variant.