PlayerContext

Trait PlayerContext 

Source
pub trait PlayerContext: Send + Sync {
    // Required methods
    fn send_message<'life0, 'async_trait>(
        &'life0 self,
        msg: ServerMessage,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn identity(&self) -> &dyn PlayerIdentity;
    fn is_admin(&self) -> bool;
    fn lobby_id(&self) -> Option<&str>;
    fn game_id(&self) -> Option<&str>;
    fn is_spectating(&self) -> bool;
    fn is_connected(&self) -> bool;

    // Provided methods
    fn player_id(&self) -> i64 { ... }
    fn in_lobby(&self) -> bool { ... }
    fn in_game(&self) -> bool { ... }
}

Required Methods§

Source

fn send_message<'life0, 'async_trait>( &'life0 self, msg: ServerMessage, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn identity(&self) -> &dyn PlayerIdentity

Get the player’s identity.

Source

fn is_admin(&self) -> bool

Check if the player has admin privileges.

Source

fn lobby_id(&self) -> Option<&str>

Get the current lobby ID if in a lobby.

Source

fn game_id(&self) -> Option<&str>

Get the current game ID if in a game.

Source

fn is_spectating(&self) -> bool

Check if the player is spectating.

Source

fn is_connected(&self) -> bool

Check if the player is connected.

Provided Methods§

Source

fn player_id(&self) -> i64

Get player ID directly (convenience for identity().player_id()).

Source

fn in_lobby(&self) -> bool

Check if the player is in a lobby.

Source

fn in_game(&self) -> bool

Check if the player is in a game.

Implementors§