opensearch-client 0.3.1

Strongly typed OpenSearch Client
Documentation
/*
 * opensearch-client
 *
 * Rust Client for OpenSearch
 *
 * The version of the OpenAPI document: 3.1.0
 * Contact: alberto.paro@gmail.com
 * Generated by Paro OpenAPI Generator
 */
use serde::{Deserialize, Serialize};



#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WaitForNodes {
    StringValue(String),
    CountValue(u64),
}

impl std::fmt::Display for WaitForNodes {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            WaitForNodes::StringValue(s) => write!(f, "{}", s),
            WaitForNodes::CountValue(n) => write!(f, "{}", n),
        }
    }
}


impl WaitForNodes {
    pub fn as_str(&self) -> String {
        match self {
            WaitForNodes::StringValue(s) => s.clone(),
            WaitForNodes::CountValue(n) => n.to_string(),
        }
    }

    pub fn as_num(&self) -> Option<u64> {
        match self {
            WaitForNodes::CountValue(n) => Some(*n),
            _ => None,
        }
    }
}

impl From<u64> for WaitForNodes {
    fn from(n: u64) -> Self {
        WaitForNodes::CountValue(n)
    }
}

impl From<&str> for WaitForNodes {
    fn from(s: &str) -> Self {
        WaitForNodes::StringValue(s.to_string())
    }
}

impl From<String> for WaitForNodes {
    fn from(s: String) -> Self {
        WaitForNodes::StringValue(s)
    }
}