pub struct TokenMetadata {
pub update_authority: OptionalNonZeroPubkey,
pub mint: Pubkey,
pub name: String,
pub symbol: String,
pub uri: String,
pub additional_metadata: Vec<(String, String)>,
}
Expand description
Data struct for all token-metadata, stored in a TLV entry
The type and length parts must be handled by the TLV library, and not stored as part of this struct.
Fields§
The authority that can sign to update the metadata
mint: Pubkey
The associated mint, used to counter spoofing to be sure that metadata belongs to a particular mint
name: String
The longer name of the token
symbol: String
The shortened symbol for the token
uri: String
The URI pointing to richer metadata
additional_metadata: Vec<(String, String)>
Any additional metadata about the token as key-value pairs. The program must avoid storing the same key twice.
Implementations§
Source§impl TokenMetadata
impl TokenMetadata
Sourcepub fn tlv_size_of(&self) -> Result<usize, ProgramError>
pub fn tlv_size_of(&self) -> Result<usize, ProgramError>
Gives the total size of this struct as a TLV entry in an account
Sourcepub fn set_key_value(&mut self, new_key: String, new_value: String)
pub fn set_key_value(&mut self, new_key: String, new_value: String)
Sets a key-value pair in the additional metadata
If the key is already present, overwrites the existing entry. Otherwise, adds it to the end.
Sourcepub fn remove_key(&mut self, key: &str) -> bool
pub fn remove_key(&mut self, key: &str) -> bool
Removes the key-value pair given by the provided key. Returns true if the key was found.
Trait Implementations§
Source§impl BorshDeserialize for TokenMetadata
impl BorshDeserialize for TokenMetadata
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSchema for TokenMetadata
impl BorshSchema for TokenMetadata
Source§fn declaration() -> Declaration
fn declaration() -> Declaration
Source§fn add_definitions_recursively(
definitions: &mut BTreeMap<Declaration, Definition>,
)
fn add_definitions_recursively( definitions: &mut BTreeMap<Declaration, Definition>, )
Source§impl BorshSerialize for TokenMetadata
impl BorshSerialize for TokenMetadata
Source§impl Clone for TokenMetadata
impl Clone for TokenMetadata
Source§fn clone(&self) -> TokenMetadata
fn clone(&self) -> TokenMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TokenMetadata
impl Debug for TokenMetadata
Source§impl Default for TokenMetadata
impl Default for TokenMetadata
Source§fn default() -> TokenMetadata
fn default() -> TokenMetadata
Source§impl PartialEq for TokenMetadata
impl PartialEq for TokenMetadata
Source§impl SplDiscriminate for TokenMetadata
impl SplDiscriminate for TokenMetadata
Source§const SPL_DISCRIMINATOR: ArrayDiscriminator = _
const SPL_DISCRIMINATOR: ArrayDiscriminator = _
Please use this discriminator in your program when matching
Source§const SPL_DISCRIMINATOR_SLICE: &'static [u8] = _
const SPL_DISCRIMINATOR_SLICE: &'static [u8] = _
&[u8]
)Source§impl VariableLenPack for TokenMetadata
impl VariableLenPack for TokenMetadata
Source§fn pack_into_slice(&self, dst: &mut [u8]) -> Result<(), ProgramError>
fn pack_into_slice(&self, dst: &mut [u8]) -> Result<(), ProgramError>
Source§fn unpack_from_slice(src: &[u8]) -> Result<Self, ProgramError>
fn unpack_from_slice(src: &[u8]) -> Result<Self, ProgramError>
Source§fn get_packed_len(&self) -> Result<usize, ProgramError>
fn get_packed_len(&self) -> Result<usize, ProgramError>
impl StructuralPartialEq for TokenMetadata
Auto Trait Implementations§
impl Freeze for TokenMetadata
impl RefUnwindSafe for TokenMetadata
impl Send for TokenMetadata
impl Sync for TokenMetadata
impl Unpin for TokenMetadata
impl UnwindSafe for TokenMetadata
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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