Trait Pack

Source
pub trait Pack: Sealed {
    const LEN: usize;

    // Provided methods
    fn get_packed_len() -> usize { ... }
    fn unpack(input: &[u8]) -> Result<Self, ProgramError>
       where Self: IsInitialized { ... }
    fn unpack_unchecked(input: &[u8]) -> Result<Self, ProgramError> { ... }
    fn pack(src: Self, dst: &mut [u8]) -> Result<(), ProgramError> { ... }
}
Expand description

Safely and efficiently (de)serialize account state

Required Associated Constantsยง

Source

const LEN: usize

The length, in bytes, of the packed representation

Provided Methodsยง

Source

fn get_packed_len() -> usize

Get the packed length

Source

fn unpack(input: &[u8]) -> Result<Self, ProgramError>
where Self: IsInitialized,

Unpack from slice and check if initialized

Source

fn unpack_unchecked(input: &[u8]) -> Result<Self, ProgramError>

Unpack from slice without checking if initialized

Source

fn pack(src: Self, dst: &mut [u8]) -> Result<(), ProgramError>

Pack into slice

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.

Implementations on Foreign Typesยง

Sourceยง

impl Pack for Account

Sourceยง

const LEN: usize = 165usize

Sourceยง

impl Pack for Mint

Sourceยง

const LEN: usize = 82usize

Sourceยง

impl Pack for Multisig

Sourceยง

const LEN: usize = 355usize

Sourceยง

impl Pack for Account

Sourceยง

const LEN: usize = 165usize

Sourceยง

impl Pack for Mint

Sourceยง

const LEN: usize = 82usize

Sourceยง

impl Pack for Multisig

Sourceยง

const LEN: usize = 355usize

Implementorsยง