lemon_bugsnag_rs 0.1.2

A library for interacting with the BugSnag error-reporting and sessions APIs.
Documentation
use std::fmt::{Display, Formatter, Result};

use serde::Serialize;

/// Enum corresponding to the `events -> app -> binary_arch` key in the BugSnag
/// error-reporting API payload. Represents the architecture of the running
/// binary
///
///
/// ```
/// use lemon_bugsnag_rs::error::payload::events::enums::BinaryArch;
///
/// let binary_arch_variant = BinaryArch::Amd64;
///
/// match binary_arch_variant {
///     BinaryArch::X86 => () /* Not this one */,
///     BinaryArch::X86_64 => () /* Not this one */,
///     BinaryArch::Arm32 => () /* Not this one */,
///     BinaryArch::Amd64 => {
///         // Ah, here we go
///         // Do stuff...
///     },
///     _ => () // Catch-all for remaining variants
/// }
/// ```
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum BinaryArch {
    /// Represents X86 platforms
    X86,
    /// Represents X86_64 platforms
    X86_64,
    /// Represents Arm32 platforms
    Arm32,
    /// Represents Arm64 platforms
    Arm64,
    /// Represents Arm64e platforms
    Arm64e,
    /// Represents Armv6 platforms
    Armv6,
    /// Represents Armv7 platforms
    Armv7,
    /// Represents Armv7f platforms
    Armv7f,
    /// Represents Armv7k platforms
    Armv7k,
    /// Represents Armv7s platforms
    Armv7s,
    /// Represents Armv8 platforms
    Armv8,
    /// Represents Amd64 platforms
    Amd64,
}

impl Display for BinaryArch {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        let output = format!("{:?}", self).to_lowercase();

        write!(f, "{}", output)
    }
}

impl Serialize for BinaryArch {
    fn serialize<S>(
        &self,
        serializer: S,
    ) -> std::prelude::v1::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        let output = format!("{:?}", self).to_lowercase();

        serializer.serialize_str(&output)
    }
}