Trait InstructionData

Source
pub trait InstructionData: Discriminator + AnchorSerialize {
    // Provided methods
    fn data(&self) -> Vec<u8>  { ... }
    fn write_to(&self, data: &mut Vec<u8>) { ... }
}
Expand description

Calculates the data for an instruction invocation, where the data is Discriminator + BorshSerialize(args). args is a borsh serialized struct of named fields for each argument given to an instruction.

Provided Methods§

Source

fn data(&self) -> Vec<u8>

Source

fn write_to(&self, data: &mut Vec<u8>)

Clears data and writes instruction data to it.

We use a Vec<u8>`` here because of the additional flexibility of re-allocation (only if necessary), and because the data field in Instructionexpects aVec`.

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§