zulip-api 0.0.8

Client library for interacting with the Zulip API
Documentation
use serde::{Deserialize, Serialize};

use crate::{impl_default, impl_display};

/// Represents whether to add or remove a flag.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum Operation {
    Add,
    Remove,
}

impl Operation {
    /// Represent the string value for the `add` operation.
    pub const ADD: &str = "add";
    /// Represent the string value for the `remove` operation.
    pub const REMOVE: &str = "remove";

    /// Creates a new [Operation].
    pub const fn new() -> Self {
        Self::Add
    }

    /// Gets the string representation of the [Operation].
    pub const fn as_str(&self) -> &'static str {
        match self {
            Self::Add => Self::ADD,
            Self::Remove => Self::REMOVE,
        }
    }
}

impl_default!(Operation);
impl_display!(Operation: str);