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 UnassignedInformation {
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub at: ::core::option::Option<crate::DateTime>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub last_allocation_status: ::core::option::Option<::std::string::String>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub reason:
        ::core::option::Option<crate::cluster::allocation_explain::UnassignedInformationReason>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub details: ::core::option::Option<::std::string::String>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub failed_allocation_attempts: ::core::option::Option<i32>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub delayed: ::core::option::Option<bool>,
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub allocation_status: ::core::option::Option<::std::string::String>,
}

impl UnassignedInformation {
    /// A `UnassignedInformation` with its required properties set.
    pub fn new(
        at: impl ::core::convert::Into<crate::DateTime>,
        reason: impl ::core::convert::Into<
            crate::cluster::allocation_explain::UnassignedInformationReason,
        >,
    ) -> Self {
        Self {
            at: ::core::option::Option::Some(at.into()),
            last_allocation_status: ::core::option::Option::None,
            reason: ::core::option::Option::Some(reason.into()),
            details: ::core::option::Option::None,
            failed_allocation_attempts: ::core::option::Option::None,
            delayed: ::core::option::Option::None,
            allocation_status: ::core::option::Option::None,
        }
    }
}

impl UnassignedInformation {
    /// Sets `last_allocation_status`.
    pub fn last_allocation_status(
        mut self,
        value: impl ::core::convert::Into<::std::string::String>,
    ) -> Self {
        self.last_allocation_status = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `details`.
    pub fn details(mut self, value: impl ::core::convert::Into<::std::string::String>) -> Self {
        self.details = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `failed_allocation_attempts`.
    pub fn failed_allocation_attempts(mut self, value: i32) -> Self {
        self.failed_allocation_attempts = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `delayed`.
    pub fn delayed(mut self, value: bool) -> Self {
        self.delayed = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `allocation_status`.
    pub fn allocation_status(
        mut self,
        value: impl ::core::convert::Into<::std::string::String>,
    ) -> Self {
        self.allocation_status = ::core::option::Option::Some(value.into());
        self
    }
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum UnassignedInformationReason {
    /// `INDEX_CREATED`
    INDEXCREATED,
    /// `CLUSTER_RECOVERED`
    CLUSTERRECOVERED,
    /// `INDEX_REOPENED`
    INDEXREOPENED,
    /// `DANGLING_INDEX_IMPORTED`
    DANGLINGINDEXIMPORTED,
    /// `NEW_INDEX_RESTORED`
    NEWINDEXRESTORED,
    /// `EXISTING_INDEX_RESTORED`
    EXISTINGINDEXRESTORED,
    /// `REPLICA_ADDED`
    REPLICAADDED,
    /// `ALLOCATION_FAILED`
    ALLOCATIONFAILED,
    /// `NODE_LEFT`
    NODELEFT,
    /// `REROUTE_CANCELLED`
    REROUTECANCELLED,
    /// `REINITIALIZED`
    REINITIALIZED,
    /// `REALLOCATED_REPLICA`
    REALLOCATEDREPLICA,
    /// `PRIMARY_FAILED`
    PRIMARYFAILED,
    /// `FORCED_EMPTY_PRIMARY`
    FORCEDEMPTYPRIMARY,
    /// `MANUAL_ALLOCATION`
    MANUALALLOCATION,
    /// A value this version of the specification doesn't list.
    Raw(::std::string::String),
}

impl UnassignedInformationReason {
    /// The value as Elasticsearch writes it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::INDEXCREATED => "INDEX_CREATED",
            Self::CLUSTERRECOVERED => "CLUSTER_RECOVERED",
            Self::INDEXREOPENED => "INDEX_REOPENED",
            Self::DANGLINGINDEXIMPORTED => "DANGLING_INDEX_IMPORTED",
            Self::NEWINDEXRESTORED => "NEW_INDEX_RESTORED",
            Self::EXISTINGINDEXRESTORED => "EXISTING_INDEX_RESTORED",
            Self::REPLICAADDED => "REPLICA_ADDED",
            Self::ALLOCATIONFAILED => "ALLOCATION_FAILED",
            Self::NODELEFT => "NODE_LEFT",
            Self::REROUTECANCELLED => "REROUTE_CANCELLED",
            Self::REINITIALIZED => "REINITIALIZED",
            Self::REALLOCATEDREPLICA => "REALLOCATED_REPLICA",
            Self::PRIMARYFAILED => "PRIMARY_FAILED",
            Self::FORCEDEMPTYPRIMARY => "FORCED_EMPTY_PRIMARY",
            Self::MANUALALLOCATION => "MANUAL_ALLOCATION",
            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 {
            "INDEX_CREATED" => ::core::option::Option::Some(Self::INDEXCREATED),
            "CLUSTER_RECOVERED" => ::core::option::Option::Some(Self::CLUSTERRECOVERED),
            "INDEX_REOPENED" => ::core::option::Option::Some(Self::INDEXREOPENED),
            "DANGLING_INDEX_IMPORTED" => ::core::option::Option::Some(Self::DANGLINGINDEXIMPORTED),
            "NEW_INDEX_RESTORED" => ::core::option::Option::Some(Self::NEWINDEXRESTORED),
            "EXISTING_INDEX_RESTORED" => ::core::option::Option::Some(Self::EXISTINGINDEXRESTORED),
            "REPLICA_ADDED" => ::core::option::Option::Some(Self::REPLICAADDED),
            "ALLOCATION_FAILED" => ::core::option::Option::Some(Self::ALLOCATIONFAILED),
            "NODE_LEFT" => ::core::option::Option::Some(Self::NODELEFT),
            "REROUTE_CANCELLED" => ::core::option::Option::Some(Self::REROUTECANCELLED),
            "REINITIALIZED" => ::core::option::Option::Some(Self::REINITIALIZED),
            "REALLOCATED_REPLICA" => ::core::option::Option::Some(Self::REALLOCATEDREPLICA),
            "PRIMARY_FAILED" => ::core::option::Option::Some(Self::PRIMARYFAILED),
            "FORCED_EMPTY_PRIMARY" => ::core::option::Option::Some(Self::FORCEDEMPTYPRIMARY),
            "MANUAL_ALLOCATION" => ::core::option::Option::Some(Self::MANUALALLOCATION),
            _ => ::core::option::Option::None,
        }
    }
}

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