pub struct Client { /* private fields */ }Expand description
Network player that communicates via tokio channels. Designed to bridge WebSocket connections to the Room actor system.
The tx channel sends JSON (ServerMessage) to the WebSocket client. The rx channel receives action strings from the WebSocket client.
Implementations§
Trait Implementations§
Source§impl Player for Client
impl Player for Client
Source§fn alive(&self) -> bool
fn alive(&self) -> bool
Check if the player is still connected.
Returns false when the player has disconnected (channel closed, etc.).
Default implementation returns true (CPU players are always alive).
Source§fn decide<'life0, 'life1, 'async_trait>(
&'life0 mut self,
recall: &'life1 Partial,
) -> Pin<Box<dyn Future<Output = Action> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn decide<'life0, 'life1, 'async_trait>(
&'life0 mut self,
recall: &'life1 Partial,
) -> Pin<Box<dyn Future<Output = Action> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Make a decision given complete game state.
Called when it’s this player’s turn to act.
Recall contains all information visible to this player.
Source§fn notify<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn notify<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: &'life1 Event,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Receive notification of game events.
Called for all public actions and private events relevant to this player.
Useful for updating UI, logging, or maintaining local state.
Not required for decision-making (Partial is self-contained).
Auto Trait Implementations§
impl Freeze for Client
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more