pub trait SolanaSysvar: SysvarId + Default + Sized + Serialize + DeserializeOwned {
    // Provided methods
    fn size_of() -> usize { ... }
    fn from_account_info(
        account_info: &AccountInfo<'_>
    ) -> Result<Self, ProgramError> { ... }
    fn to_account_info(&self, account_info: &mut AccountInfo<'_>) -> Option<()> { ... }
    fn get() -> Result<Self, ProgramError> { ... }
}
Expand description

A type that holds sysvar data.

Provided Methods§

fn size_of() -> usize

The size in bytes of the sysvar as serialized account data.

fn from_account_info( account_info: &AccountInfo<'_> ) -> Result<Self, ProgramError>

Deserializes the sysvar from its AccountInfo.

§Errors

If account_info does not have the same ID as the sysvar this function returns ProgramError::InvalidArgument.

fn to_account_info(&self, account_info: &mut AccountInfo<'_>) -> Option<()>

Serializes the sysvar to AccountInfo.

§Errors

Returns None if serialization failed.

fn get() -> Result<Self, ProgramError>

Load the sysvar directly from the runtime.

This is the preferred way to load a sysvar. Calling this method does not incur any deserialization overhead, and does not require the sysvar account to be passed to the program.

Not all sysvars support this method. If not, it returns ProgramError::UnsupportedSysvar.

Object Safety§

This trait is not object safe.

Implementors§

§

impl Sysvar for Clock

§

impl Sysvar for EpochSchedule

§

impl Sysvar for Rent

§

impl Sysvar for Rewards

§

impl Sysvar for SlotHashes

§

impl Sysvar for SlotHistory

§

impl Sysvar for StakeHistory

§

impl Sysvar for EpochRewards

§

impl Sysvar for Fees

§

impl Sysvar for LastRestartSlot

§

impl Sysvar for RecentBlockhashes