Trait SysvarSerialize

Source
pub trait SysvarSerialize:
    Sysvar
    + SysvarId
    + 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<()> { ... }
}
Expand description

A type that holds sysvar data.

Provided Methods§

Source

fn size_of() -> usize

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

Source

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.

Source

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

Serializes the sysvar to AccountInfo.

§Errors

Returns None if serialization failed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§