Skip to main content

api/dto/
player.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents a player in the game from the client’s perspective.
4#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
5pub enum PlayerDTO {
6    /// The current user of the API.
7    User,
8
9    /// The opponent player.
10    Opponent,
11}
12
13impl std::fmt::Display for PlayerDTO {
14    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15        let player = match self {
16            PlayerDTO::User => "You",
17            PlayerDTO::Opponent => "Opponent",
18        };
19        player.fmt(f)
20    }
21}