Event

Enum 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

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

Fields

§sender: String
§raw: Vec<u8>
§

Ready

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

§

ShareSecrets

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

Fields

§sender: String
§

OperationTimeout

Fields

§addrs: Vec<String>
§

Mask

Randomize items. This event is sent by transactors.

Fields

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

Lock

Lock items. This event is sent by transactors.

Fields

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

RandomnessReady

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

Fields

§random_id: RandomId
§

Sync

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.

Fields

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

ServerLeave

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

NOTE: This event must be handled idempotently.

Fields

§server_addr: String
§transactor_addr: String
§

Leave

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

Fields

§player_addr: String
§

GameStart

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

Fields

§access_version: u64
§

WaitingTimeout

Timeout when waiting for start

§

DrawRandomItems

Random drawer takes random items by indexes.

Fields

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

DrawTimeout

Timeout for drawing random items

§

ActionTimeout

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

Fields

§player_addr: String
§

AnswerDecision

Answer the decision question with encrypted ciphertext

Fields

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

SecretsReady

All required secrets are shared

Fields

§random_ids: Vec<usize>
§

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 Event

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 Event

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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 StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

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 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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