Skip to main content

InstructionDataBuilder

Struct InstructionDataBuilder 

Source
pub struct InstructionDataBuilder { /* private fields */ }
Expand description

Builder for encoding instruction data

Implementations§

Source§

impl InstructionDataBuilder

Source

pub fn new() -> Self

Create a new instruction data builder

Source

pub fn instruction(self, discriminant: u8) -> Self

Add a discriminant/instruction type byte

Source

pub fn bytes(self, bytes: &[u8]) -> Self

Add raw bytes

Source

pub fn u8(self, value: u8) -> Self

Add a u8 value

Source

pub fn u16(self, value: u16) -> Self

Add a u16 value (little-endian)

Source

pub fn u32(self, value: u32) -> Self

Add a u32 value (little-endian)

Source

pub fn u64(self, value: u64) -> Self

Add a u64 value (little-endian)

Source

pub fn u128(self, value: u128) -> Self

Add a u128 value (little-endian)

Source

pub fn i8(self, value: i8) -> Self

Add a i8 value

Source

pub fn i16(self, value: i16) -> Self

Add a i16 value (little-endian)

Source

pub fn i32(self, value: i32) -> Self

Add a i32 value (little-endian)

Source

pub fn i64(self, value: i64) -> Self

Add a i64 value (little-endian)

Source

pub fn i128(self, value: i128) -> Self

Add a i128 value (little-endian)

Source

pub fn bool(self, value: bool) -> Self

Add a bool value

Source

pub fn pubkey(self, pubkey: &Pubkey) -> Self

Add a pubkey (32 bytes)

Source

pub fn option_pubkey(self, pubkey: Option<&Pubkey>) -> Self

Add an optional pubkey

Source

pub fn string(self, s: &str) -> Self

Add a string (with length prefix as u32)

Source

pub fn build(self) -> Vec<u8>

Build the final data vector

Trait Implementations§

Source§

impl Default for InstructionDataBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.