oxsearch-sql 0.2.0

SQL for oxsearch, generated from the Elasticsearch specification: queries, cursors and their translation into search requests
Documentation
// Generated by `cargo run -p xtask -- generate` from elastic/elasticsearch-specification 9.5 at
// 84bf510a907bae62ffe29af35f516af287a79eab. Don't edit it: change the generator.

/// The request's body.
#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
#[non_exhaustive]
pub struct RequestBody {
    /// Cursor to clear.
    pub cursor: ::std::string::String,
}

impl RequestBody {
    /// A `RequestBody` with its required properties set.
    pub fn new(cursor: impl ::core::convert::Into<::std::string::String>) -> Self {
        Self {
            cursor: cursor.into(),
        }
    }
}

impl RequestBody {}

/// Clear an SQL search cursor.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct Request {
    /// The body.
    pub body: ::core::option::Option<crate::clear_cursor::RequestBody>,
}

impl Request {
    /// A `Request` with its required properties set.
    pub fn new() -> Self {
        Self {
            body: ::core::option::Option::None,
        }
    }
}

impl Request {
    /// Sets `body`.
    pub fn body(
        mut self,
        value: impl ::core::convert::Into<crate::clear_cursor::RequestBody>,
    ) -> Self {
        self.body = ::core::option::Option::Some(value.into());
        self
    }
}

#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
#[non_exhaustive]
pub struct Response {
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub succeeded: ::core::option::Option<bool>,
}

impl Response {
    /// A `Response` with its required properties set.
    pub fn new(succeeded: bool) -> Self {
        Self {
            succeeded: ::core::option::Option::Some(succeeded.into()),
        }
    }
}

impl Response {}

impl ::oxsearch_core::Endpoint for Request {
    type Response = crate::clear_cursor::Response;

    fn name(&self) -> &'static str {
        "sql.clear_cursor"
    }

    fn route(&self) -> ::core::result::Result<::oxsearch_core::Route, ::oxsearch_core::Error> {
        ::core::result::Result::Ok(::oxsearch_core::Route::new(
            ::oxsearch_core::Method::Post,
            "/_sql/close",
        ))
    }

    fn query(
        &self,
    ) -> ::core::result::Result<
        ::std::vec::Vec<(&'static str, ::std::string::String)>,
        ::oxsearch_core::Error,
    > {
        ::core::result::Result::Ok(::std::vec::Vec::new())
    }

    fn body(
        &self,
    ) -> ::core::result::Result<::core::option::Option<::oxsearch_core::Body>, ::oxsearch_core::Error>
    {
        self.body
            .as_ref()
            .map(|body| ::oxsearch_core::__private::json_body(body))
            .transpose()
    }
}