// Copyright 2023 Salesforce, Inc. All rights reserved.
use std::fmt;
use thiserror::Error;

#[repr(C)]
#[derive(PartialEq, Eq, Debug, Error)]
pub enum Status {
    Ok = 0,
    NotFound = 1,
    BadArgument = 2,
    ParseFailure = 4,
    Empty = 7,
    CasMismatch = 8,
    InternalFailure = 10,
}

impl fmt::Display for Status {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl Status {
    pub fn as_str(&self) -> &'static str {
        match self {
            Status::Ok => "Ok",
            Status::NotFound => "NotFound",
            Status::BadArgument => "BadArgument",
            Status::ParseFailure => "ParseFailure",
            Status::Empty => "Empty",
            Status::CasMismatch => "CasMismatch",
            Status::InternalFailure => "InternalFailure",
        }
    }
}
