oxsearch-core 0.1.0

The core of oxsearch: the transport and endpoint traits, errors, and the common types, query DSL, retrievers and kNN generated from the Elasticsearch specification
Documentation
// Generated by `cargo run -p xtask -- generate` from elastic/elasticsearch-specification 9.5 at
// 84bf510a907bae62ffe29af35f516af287a79eab. Don't edit it: change the generator.

#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
#[non_exhaustive]
pub struct ShardFileSizeInfo {
    pub description: ::std::string::String,
    pub size_in_bytes: i64,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub min_size_in_bytes: ::core::option::Option<i64>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub max_size_in_bytes: ::core::option::Option<i64>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub average_size_in_bytes: ::core::option::Option<i64>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub count: ::core::option::Option<i64>,
}

impl ShardFileSizeInfo {
    /// A `ShardFileSizeInfo` with its required properties set.
    pub fn new(
        description: impl ::core::convert::Into<::std::string::String>,
        size_in_bytes: i64,
    ) -> Self {
        Self {
            description: description.into(),
            size_in_bytes: size_in_bytes.into(),
            min_size_in_bytes: ::core::option::Option::None,
            max_size_in_bytes: ::core::option::Option::None,
            average_size_in_bytes: ::core::option::Option::None,
            count: ::core::option::Option::None,
        }
    }
}

impl ShardFileSizeInfo {
    /// Sets `min_size_in_bytes`.
    pub fn min_size_in_bytes(mut self, value: i64) -> Self {
        self.min_size_in_bytes = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `max_size_in_bytes`.
    pub fn max_size_in_bytes(mut self, value: i64) -> Self {
        self.max_size_in_bytes = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `average_size_in_bytes`.
    pub fn average_size_in_bytes(mut self, value: i64) -> Self {
        self.average_size_in_bytes = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `count`.
    pub fn count(mut self, value: i64) -> Self {
        self.count = ::core::option::Option::Some(value.into());
        self
    }
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ShardRoutingState {
    /// `UNASSIGNED`
    UNASSIGNED,
    /// `INITIALIZING`
    INITIALIZING,
    /// `STARTED`
    STARTED,
    /// `RELOCATING`
    RELOCATING,
    /// A value this version of the specification doesn't list.
    Raw(::std::string::String),
}

impl ShardRoutingState {
    /// The value as Elasticsearch writes it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::UNASSIGNED => "UNASSIGNED",
            Self::INITIALIZING => "INITIALIZING",
            Self::STARTED => "STARTED",
            Self::RELOCATING => "RELOCATING",
            Self::Raw(value) => value,
        }
    }

    /// The listed value with this name, if there is one.
    pub fn from_known(value: &str) -> ::core::option::Option<Self> {
        match value {
            "UNASSIGNED" => ::core::option::Option::Some(Self::UNASSIGNED),
            "INITIALIZING" => ::core::option::Option::Some(Self::INITIALIZING),
            "STARTED" => ::core::option::Option::Some(Self::STARTED),
            "RELOCATING" => ::core::option::Option::Some(Self::RELOCATING),
            _ => ::core::option::Option::None,
        }
    }
}

impl ::serde::Serialize for ShardRoutingState {
    fn serialize<S__: ::serde::Serializer>(
        &self,
        serializer: S__,
    ) -> ::core::result::Result<S__::Ok, S__::Error> {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de> ::serde::Deserialize<'de> for ShardRoutingState {
    fn deserialize<D__: ::serde::Deserializer<'de>>(
        deserializer: D__,
    ) -> ::core::result::Result<Self, D__::Error> {
        ::oxsearch_core::__private::deserialize_string_enum(
            deserializer,
            "ShardRoutingState",
            |value| Self::from_known(value).unwrap_or_else(|| Self::Raw(value.to_owned())),
        )
    }
}