pub enum Seed {
    Uninitialized,
    Literal {
        bytes: Vec<u8>,
    },
    InstructionData {
        index: u8,
        length: u8,
    },
    AccountKey {
        index: u8,
    },
    AccountData {
        account_index: u8,
        data_index: u8,
        length: u8,
    },
}
Expand description

Enum to describe a required seed for a Program-Derived Address

Variants§

§

Uninitialized

Uninitialized configuration byte space

§

Literal

A literal hard-coded argument Packed as: * 1 - Discriminator * 1 - Length of literal * N - Literal bytes themselves

Fields

§bytes: Vec<u8>

The literal value repesented as a vector of bytes.

For example, if a literal value is a string literal, such as “my-seed”, this value would be "my-seed".as_bytes().to_vec().

§

InstructionData

An instruction-provided argument, to be resolved from the instruction data Packed as: * 1 - Discriminator * 1 - Start index of instruction data * 1 - Length of instruction data starting at index

Fields

§index: u8

The index where the bytes of an instruction argument begin

§length: u8

The length of the instruction argument (number of bytes)

Note: Max seed length is 32 bytes, so u8 is appropriate here

§

AccountKey

The public key of an account from the entire accounts list. Note: This includes an extra accounts required.

Packed as: * 1 - Discriminator * 1 - Index of account in accounts list

Fields

§index: u8

The index of the account in the entire accounts list

§

AccountData

An argument to be resolved from the inner data of some account Packed as: * 1 - Discriminator * 1 - Index of account in accounts list * 1 - Start index of account data * 1 - Length of account data starting at index

Fields

§account_index: u8

The index of the account in the entire accounts list

§data_index: u8

The index where the bytes of an account data argument begin

§length: u8

The length of the argument (number of bytes)

Note: Max seed length is 32 bytes, so u8 is appropriate here

Implementations§

source§

impl Seed

source

pub fn tlv_size(&self) -> u8

Get the size of a seed configuration

source

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

Packs a seed configuration into a slice

source

pub fn pack_into_address_config( seeds: &[Self] ) -> Result<[u8; 32], ProgramError>

Packs a vector of seed configurations into a 32-byte array, filling the rest with 0s. Errors if it overflows.

source

pub fn unpack(bytes: &[u8]) -> Result<Self, ProgramError>

Unpacks a seed configuration from a slice

source

pub fn unpack_address_config( address_config: &[u8; 32] ) -> Result<Vec<Self>, ProgramError>

Unpacks all seed configurations from a 32-byte array. Stops when it hits uninitialized data (0s).

Trait Implementations§

source§

impl Clone for Seed

source§

fn clone(&self) -> Seed

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Seed

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Seed

source§

fn eq(&self, other: &Seed) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Seed

Auto Trait Implementations§

§

impl Freeze for Seed

§

impl RefUnwindSafe for Seed

§

impl Send for Seed

§

impl Sync for Seed

§

impl Unpin for Seed

§

impl UnwindSafe for Seed

Blanket Implementations§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V