<commit_before>//! Types for the *m.presence* event.

use ruma_identifiers::{EventId, UserId};

event! {
    /// Informs the client of a user's presence state change.
    pub struct PresenceEvent(PresenceEventContent) {
        /// The unique identifier for the event.
        pub event_id: EventId
    }
}

/// The payload of a `PresenceEvent`.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PresenceEventContent {
    /// The current avatar URL for this user.
    #[serde(skip_serializing_if="Option::is_none")]
    pub avatar_url: Option<String>,

    /// Whether or not the user is currently active.
    pub currently_active: bool,

    /// The current display name for this user.
    #[serde(skip_serializing_if="Option::is_none")]
    pub displayname: Option<String>,

    /// The last time since this used performed some action, in milliseconds.
    #[serde(skip_serializing_if="Option::is_none")]
    pub last_active_ago: Option<u64>,

    /// The presence state for this user.
    pub presence: PresenceState,

    /// The unique identifier for the user associated with this event.
    pub user_id: UserId,
}

/// A description of a user's connectivity and availability for chat.
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum PresenceState {
    /// Disconnected from the service.
    #[serde(rename="offline")]
    Offline,

    /// Connected to the service.
    #[serde(rename="online")]
    Online,

    /// Connected to the service but not available for chat.
    #[serde(rename="unavailable")]
    Unavailable,
}<commit_msg>Add missing trait implementations for PresenceState<commit_after>//! Types for the *m.presence* event.

use ruma_identifiers::{EventId, UserId};

event! {
    /// Informs the client of a user's presence state change.
    pub struct PresenceEvent(PresenceEventContent) {
        /// The unique identifier for the event.
        pub event_id: EventId
    }
}

/// The payload of a `PresenceEvent`.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PresenceEventContent {
    /// The current avatar URL for this user.
    #[serde(skip_serializing_if="Option::is_none")]
    pub avatar_url: Option<String>,

    /// Whether or not the user is currently active.
    pub currently_active: bool,

    /// The current display name for this user.
    #[serde(skip_serializing_if="Option::is_none")]
    pub displayname: Option<String>,

    /// The last time since this used performed some action, in milliseconds.
    #[serde(skip_serializing_if="Option::is_none")]
    pub last_active_ago: Option<u64>,

    /// The presence state for this user.
    pub presence: PresenceState,

    /// The unique identifier for the user associated with this event.
    pub user_id: UserId,
}

/// A description of a user's connectivity and availability for chat.
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub enum PresenceState {
    /// Disconnected from the service.
    #[serde(rename="offline")]
    Offline,

    /// Connected to the service.
    #[serde(rename="online")]
    Online,

    /// Connected to the service but not available for chat.
    #[serde(rename="unavailable")]
    Unavailable,
}

impl_enum! {
    PresenceState {
        Offline => "offline",
        Online => "online",
        Unavailable => "unavailable",
    }
}
{'fraction_non_alphanumeric': 0.11284513805522209, 'fraction_numerical': 0.0012004801920768306, 'mean_word_length': 3.2404580152671754, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6563355', 'n_tokens_mistral': 958, 'n_tokens_neox': 969, 'n_words': 323}