pub struct InitAccount {
    pub addr: String,
    pub players: Vec<PlayerJoin>,
    pub servers: Vec<ServerJoin>,
    pub data: Vec<u8>,
    pub access_version: u64,
    pub settle_version: u64,
    pub max_players: u16,
    pub checkpoint: Vec<u8>,
}
Expand description

A subset of on-chain account, used for game handler initialization. The access_version may refer to an old state when the game is started by transactor.

Fields§

§addr: String§players: Vec<PlayerJoin>§servers: Vec<ServerJoin>§data: Vec<u8>§access_version: u64§settle_version: u64§max_players: u16§checkpoint: Vec<u8>

Implementations§

source§

impl InitAccount

source

pub fn data<S: BorshDeserialize>(&self) -> Result<S, HandleError>

source

pub fn checkpoint<S: BorshDeserialize>(&self) -> Result<Option<S>, HandleError>

source

pub fn add_player<S: Into<String>>( &mut self, addr: S, position: usize, balance: u64, verify_key: String )

Add a new player. This function is only available in tests. This function will panic when a duplicated position is specified.

Trait Implementations§

source§

impl BorshDeserialize for InitAccountwhere String: BorshDeserialize, Vec<PlayerJoin>: BorshDeserialize, Vec<ServerJoin>: BorshDeserialize, Vec<u8>: BorshDeserialize, u64: BorshDeserialize, u16: BorshDeserialize,

source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
source§

impl BorshSerialize for InitAccountwhere String: BorshSerialize, Vec<PlayerJoin>: BorshSerialize, Vec<ServerJoin>: BorshSerialize, Vec<u8>: BorshSerialize, u64: BorshSerialize, u16: BorshSerialize,

source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
source§

impl Clone for InitAccount

source§

fn clone(&self) -> InitAccount

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 InitAccount

source§

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

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

impl Default for InitAccount

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere 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 Twhere 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 Twhere 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.