Skip to main content

PlayerIdentity

Trait PlayerIdentity 

Source
pub trait PlayerIdentity {
    // Required methods
    fn player_id(&self) -> i64;
    fn username(&self) -> &str;
    fn avatar_url(&self) -> &str;

    // Provided method
    fn name(&self) -> Option<&PlayerName> { ... }
}
Expand description

Core player identity - the immutable parts that identify a player.

This is embedded in all player-related structs to avoid field duplication. Contains the fields that are constant for a player’s session.

Required Methods§

Source

fn player_id(&self) -> i64

Get player ID.

Source

fn username(&self) -> &str

Get the raw Discord username (the unique handle). For display, use name().

Source

fn avatar_url(&self) -> &str

Get avatar URL.

Provided Methods§

Source

fn name(&self) -> Option<&PlayerName>

What to call this player in their current context, if the server resolved it. None means “show username”.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§