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, Eq, Hash)]
#[non_exhaustive]
pub enum EmbeddingContentFormat {
    /// `text`
    Text,
    /// `base64`
    Base64,
    /// A value this version of the specification doesn't list.
    Raw(::std::string::String),
}

impl EmbeddingContentFormat {
    /// The value as Elasticsearch writes it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Text => "text",
            Self::Base64 => "base64",
            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 {
            "text" => ::core::option::Option::Some(Self::Text),
            "base64" => ::core::option::Option::Some(Self::Base64),
            _ => ::core::option::Option::None,
        }
    }
}

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

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum EmbeddingContentType {
    /// `text`
    Text,
    /// `image`
    Image,
    /// `audio`
    Audio,
    /// `video`
    Video,
    /// `pdf`
    Pdf,
    /// A value this version of the specification doesn't list.
    Raw(::std::string::String),
}

impl EmbeddingContentType {
    /// The value as Elasticsearch writes it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::Text => "text",
            Self::Image => "image",
            Self::Audio => "audio",
            Self::Video => "video",
            Self::Pdf => "pdf",
            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 {
            "text" => ::core::option::Option::Some(Self::Text),
            "image" => ::core::option::Option::Some(Self::Image),
            "audio" => ::core::option::Option::Some(Self::Audio),
            "video" => ::core::option::Option::Some(Self::Video),
            "pdf" => ::core::option::Option::Some(Self::Pdf),
            _ => ::core::option::Option::None,
        }
    }
}

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