Struct race_client::Client

source ·
pub struct Client {
    pub encryptor: Arc<dyn EncryptorT>,
    pub transport: Arc<dyn TransportT>,
    pub connection: Arc<dyn ConnectionT>,
    pub game_addr: String,
    pub addr: String,
    pub mode: ClientMode,
    pub op_hist: BTreeSet<OpIdent>,
    pub secret_state: SecretState,
}
Expand description

The client core for player, transactor and validator nodes.

It reads the updated context, generates events and sends them via connection.

Client Mode

Three modes are supported:

ModeRandomizeDecisionsDecryption
Clientxoo
Serveroxo
Validatoroxo

Fields§

§encryptor: Arc<dyn EncryptorT>§transport: Arc<dyn TransportT>§connection: Arc<dyn ConnectionT>§game_addr: String§addr: String§mode: ClientMode§op_hist: BTreeSet<OpIdent>§secret_state: SecretState

Implementations§

source§

impl Client

source

pub fn new( addr: String, game_addr: String, mode: ClientMode, transport: Arc<dyn TransportT>, encryptor: Arc<dyn EncryptorT>, connection: Arc<dyn ConnectionT> ) -> Self

source

pub async fn attach_game(&self) -> Result<()>

source

pub async fn submit_event(&self, event: Event) -> Result<()>

source

pub async fn submit_custom_event<S: CustomEvent>( &self, custom_event: S ) -> Result<()>

source

pub fn load_random_states(&mut self, game_context: &GameContext) -> Result<()>

source

pub fn answer_event( &mut self, decision_id: DecisionId, value: String ) -> Result<Event>

source

pub async fn answer( &mut self, decision_id: DecisionId, value: String ) -> Result<()>

source

pub fn handle_decision( &mut self, game_context: &GameContext ) -> Result<Vec<Event>>

source

pub fn handle_random_waiting( &mut self, random_state: &RandomState ) -> Result<Option<Event>>

source

pub fn handle_random_masking( &mut self, random_state: &RandomState ) -> Result<Option<Event>>

source

pub fn handle_random_locking( &mut self, random_state: &RandomState ) -> Result<Option<Event>>

source

pub fn handle_randomization( &mut self, game_context: &GameContext ) -> Result<Vec<Event>>

source

pub fn handle_updated_context( &mut self, ctx: &GameContext ) -> Result<Vec<Event>>

source

pub fn flush_secret_states(&mut self)

source

pub fn decrypt( &self, ctx: &GameContext, random_id: RandomId ) -> Result<HashMap<usize, String>>

Decrypt the ciphertexts with shared secrets. Return a mapping from mapping from indexes to decrypted value.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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