Enum race_api::event::Event

source ·
pub enum Event {
Show 18 variants Custom { sender: String, raw: Vec<u8>, }, Ready, ShareSecrets { sender: String, shares: Vec<SecretShare>, }, OperationTimeout { addrs: Vec<String>, }, Mask { sender: String, random_id: RandomId, ciphertexts: Vec<Ciphertext>, }, Lock { sender: String, random_id: RandomId, ciphertexts_and_digests: Vec<(Ciphertext, SecretDigest)>, }, RandomnessReady { random_id: RandomId, }, Sync { new_players: Vec<PlayerJoin>, new_servers: Vec<ServerJoin>, transactor_addr: String, access_version: u64, }, ServerLeave { server_addr: String, transactor_addr: String, }, Leave { player_addr: String, }, GameStart { access_version: u64, }, WaitingTimeout, DrawRandomItems { sender: String, random_id: usize, indexes: Vec<usize>, }, DrawTimeout, ActionTimeout { player_addr: String, }, AnswerDecision { sender: String, decision_id: DecisionId, ciphertext: Ciphertext, digest: SecretDigest, }, SecretsReady { random_ids: Vec<usize>, }, Shutdown,
}
Expand description

Game event structure

Variants§

§

Custom

Fields

§sender: String
§raw: Vec<u8>

Sent by player clients. Represent game specific events, the raw parts is the serialized data from a custom game event which satisfies CustomEvent.

§

Ready

A event sent by system, the first event sent by transactor when game is loaded.

§

ShareSecrets

Fields

§sender: String

Transactor shares its secert to specific player. The secret_data is encrypted with the receiver’s public key.

§

OperationTimeout

Fields

§addrs: Vec<String>
§

Mask

Fields

§sender: String
§random_id: RandomId
§ciphertexts: Vec<Ciphertext>

Randomize items. This event is sent by transactors.

§

Lock

Fields

§sender: String
§random_id: RandomId
§ciphertexts_and_digests: Vec<(Ciphertext, SecretDigest)>

Lock items. This event is sent by transactors.

§

RandomnessReady

Fields

§random_id: RandomId

All randomness is prepared. This event is sent by transactor.

§

Sync

Fields

§new_players: Vec<PlayerJoin>
§new_servers: Vec<ServerJoin>
§transactor_addr: String
§access_version: u64

Sync with on-chain account. New players/servers will be added frist to game context and then to game handler (WASM). This event is sent by transactor based on the diff of the account states.

§

ServerLeave

Fields

§server_addr: String
§transactor_addr: String

A server left the game. transactor_addr is the new current transactor address.

NOTE: This event must be handled idempotently.

§

Leave

Fields

§player_addr: String

Client left game This event is sent by transactor based on client’s connection status.

§

GameStart

Fields

§access_version: u64

Transactor uses this event as the start for each game. The access_version can be used to filter out which players are included.

§

WaitingTimeout

Timeout when waiting for start

§

DrawRandomItems

Fields

§sender: String
§random_id: usize
§indexes: Vec<usize>

Random drawer takes random items by indexes.

§

DrawTimeout

Timeout for drawing random items

§

ActionTimeout

Fields

§player_addr: String

Timeout when waiting for player’s action Sent by transactor.

§

AnswerDecision

Fields

§sender: String
§decision_id: DecisionId
§ciphertext: Ciphertext

Answer the decision question with encrypted ciphertext

§

SecretsReady

Fields

§random_ids: Vec<usize>

All required secrets are shared

§

Shutdown

Shutdown

Implementations§

source§

impl Event

source

pub fn custom<S: Into<String>, E: CustomEvent>(sender: S, e: &E) -> Self

Trait Implementations§

source§

impl BorshDeserialize for Eventwhere String: BorshDeserialize, Vec<u8>: BorshDeserialize, Vec<SecretShare>: BorshDeserialize, Vec<String>: BorshDeserialize, RandomId: BorshDeserialize, Vec<Ciphertext>: BorshDeserialize, Vec<(Ciphertext, SecretDigest)>: BorshDeserialize, Vec<PlayerJoin>: BorshDeserialize, Vec<ServerJoin>: BorshDeserialize, u64: BorshDeserialize, usize: BorshDeserialize, Vec<usize>: BorshDeserialize, DecisionId: BorshDeserialize, Ciphertext: BorshDeserialize, SecretDigest: 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 Eventwhere String: BorshSerialize, Vec<u8>: BorshSerialize, Vec<SecretShare>: BorshSerialize, Vec<String>: BorshSerialize, RandomId: BorshSerialize, Vec<Ciphertext>: BorshSerialize, Vec<(Ciphertext, SecretDigest)>: BorshSerialize, Vec<PlayerJoin>: BorshSerialize, Vec<ServerJoin>: BorshSerialize, u64: BorshSerialize, usize: BorshSerialize, Vec<usize>: BorshSerialize, DecisionId: BorshSerialize, Ciphertext: BorshSerialize, SecretDigest: 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 Event

source§

fn clone(&self) -> Event

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 Event

source§

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

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

impl Display for Event

source§

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

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

impl PartialEq for Event

source§

fn eq(&self, other: &Event) -> 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 Eq for Event

source§

impl StructuralEq for Event

source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.