diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index afa6ddb5..511782b5 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -34,10 +34,6 @@ add_or_update_documents_1: |- id: usize, title: String } - impl Document for IncompleteMovie { - type UIDType = usize; - fn get_uid(&self) -> &Self::UIDType { &self.id } - } let task: Task = client.index("movies").add_or_update(&[ IncompleteMovie { @@ -369,7 +365,6 @@ settings_guide_sortable_1: |- add_movies_json_1: |- use meilisearch_sdk::{ indexes::*, - document::*, client::*, search::*, settings::* @@ -397,10 +392,6 @@ documents_guide_add_movie_1: |- id: String, title: String } - impl Document for IncompleteMovie { - type UIDType = String; - fn get_uid(&self) -> &Self::UIDType { &self.id } - } // Add a document to our index let task: Task = client.index("movies").add_documents(&[ @@ -420,10 +411,6 @@ document_guide_add_document_primary_key: |- overview: String, release_date: String } - impl Document for Movie { - type UIDType = String; - fn get_uid(&self) -> &Self::UIDType { &self.id } - } let task: Task = client.index("movies").add_documents(&[ Movie { @@ -459,10 +446,6 @@ getting_started_add_documents_md: |- release_date: i64, genres: Vec } - impl Document for Movie { - type UIDType = String; - fn get_uid(&self) -> &Self::UIDType { &self.id } - } ``` You will often need this `Movie` struct in other parts of this documentation. (you will have to change it a bit sometimes) @@ -475,11 +458,6 @@ getting_started_add_documents_md: |- #[serde(flatten)] value: serde_json::Value, } - - impl Document for Movie { - type UIDType = String; - fn get_uid(&self) -> &Self::UIDType { &self.id } - } ``` Then, add documents into the index: @@ -487,7 +465,6 @@ getting_started_add_documents_md: |- ```rust use meilisearch_sdk::{ indexes::*, - document::*, client::*, search::*, settings::* @@ -601,11 +578,6 @@ getting_started_add_meteorites: |- _geo: Geo } - impl Document for Meteorite { - type UIDType = String; - fn get_uid(&self) -> &Self::UIDType { &self.id } - } - let mut file = File::open("meteorites.json")?; let meteorites: Vec = serde_json::from_reader(file)?; @@ -812,10 +784,6 @@ landing_getting_started_1: |- id: String, title: String } - impl Document for Movie { - type UIDType = String; - fn get_uid(&self) -> &Self::UIDType { &self.id } - } client.index("movies").add_documents(&[ Movie { "id": "1".to_string(), "title": "Carol".to_string() }, diff --git a/examples/web_app/src/document.rs b/examples/web_app/src/document.rs index d20f7116..0a5bb15a 100644 --- a/examples/web_app/src/document.rs +++ b/examples/web_app/src/document.rs @@ -1,4 +1,3 @@ -use meilisearch_sdk::document::Document; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; use yew::prelude::*; @@ -15,14 +14,6 @@ pub struct Crate { } // Implement the Document trait so that we can use our struct with Meilisearch -impl Document for Crate { - type UIDType = String; - - fn get_uid(&self) -> &Self::UIDType { - &self.name - } -} - fn get_readable_download_count(this: &Map) -> String { if let Some(downloads) = this["downloads"].as_f64() { if downloads < 1000.0 { diff --git a/src/client.rs b/src/client.rs index f2a1aff9..b57d5ef5 100644 --- a/src/client.rs +++ b/src/client.rs @@ -176,7 +176,7 @@ impl Client { uid: impl AsRef, primary_key: Option<&str>, ) -> Result { - Ok(request::( + request::( &format!("{}/indexes", self.host), &self.api_key, Method::Post(json!({ @@ -185,19 +185,19 @@ impl Client { })), 202, ) - .await?) + .await } /// Delete an index from its UID. /// To delete an [Index], use the [Index::delete] method. pub async fn delete_index(&self, uid: impl AsRef) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!("{}/indexes/{}", self.host, uid.as_ref()), &self.api_key, Method::Delete, 202, ) - .await?) + .await } /// Alias for [Client::list_all_indexes]. @@ -467,7 +467,7 @@ impl Client { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, document, indexes::*, tasks::Task}; + /// # use meilisearch_sdk::{client::*, indexes::*, tasks::Task}; /// # use serde::{Serialize, Deserialize}; /// # /// # #[derive(Debug, Serialize, Deserialize, PartialEq)] @@ -477,13 +477,6 @@ impl Client { /// # kind: String, /// # } /// # - /// # impl document::Document for Document { - /// # type UIDType = usize; - /// # - /// # fn get_uid(&self) -> &Self::UIDType { - /// # &self.id - /// # } - /// # } /// # /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); diff --git a/src/document.rs b/src/document.rs deleted file mode 100644 index f928e687..00000000 --- a/src/document.rs +++ /dev/null @@ -1,42 +0,0 @@ -use serde::{de::DeserializeOwned, Serialize}; -use std::fmt::Display; - -/// Documents are not a predefined structure. -/// You can use your structs as documents by implementing that trait. -/// -/// **WARNING**! The get_uid() method **MUST** only return an object that displays himself only using alphanumeric characters, '/' and '-'. -/// Otherwise, the Meilisearch server will reject your documents. -/// -/// *To be able to use derive with serde, put this line on your Cargo.toml: `serde = {version="1.0", features=["derive"]}`.* -/// -/// # Example -/// -/// ``` -/// # use meilisearch_sdk::document::Document; -/// use serde::{Serialize, Deserialize}; -/// -/// #[derive(Serialize, Deserialize, Debug)] -/// struct Movie { -/// id: usize, -/// name: String, -/// description: String, -/// } -/// -/// impl Document for Movie { -/// type UIDType = usize; -/// -/// fn get_uid(&self) -> &Self::UIDType { -/// &self.id -/// } -/// } -/// ``` -pub trait Document: DeserializeOwned + std::fmt::Debug + Serialize { - /// The type of the primary key - type UIDType: Display; - - /// The method returning the primary key of the Document. - /// - /// **WARNING**! This method **MUST** only return an object that displays himself only using alphanumeric characters, '/' and '-'. - /// Otherwise, the Meilisearch server will reject your document. - fn get_uid(&self) -> &Self::UIDType; -} diff --git a/src/indexes.rs b/src/indexes.rs index e880144c..bba2c31a 100644 --- a/src/indexes.rs +++ b/src/indexes.rs @@ -1,4 +1,4 @@ -use crate::{client::Client, document::*, errors::Error, request::*, search::*, tasks::*, Rc}; +use crate::{client::Client,errors::Error, request::*, search::*, tasks::*, Rc}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde_json::json; use std::{collections::HashMap, fmt::Display, time::Duration}; @@ -106,13 +106,13 @@ impl Index { /// # }); /// ``` pub async fn delete(self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!("{}/indexes/{}", self.client.host, self.uid), &self.client.api_key, Method::Delete, 202, ) - .await?) + .await } /// Search for documents matching a specific query in the index.\ @@ -122,20 +122,13 @@ impl Index { /// /// ``` /// use serde::{Serialize, Deserialize}; - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, search::*}; + /// # use meilisearch_sdk::{client::*, indexes::*, search::*}; /// /// #[derive(Serialize, Deserialize, Debug)] /// struct Movie { /// name: String, /// description: String, /// } - /// // that trait is used by the sdk when the primary key is needed - /// impl Document for Movie { - /// type UIDType = String; - /// fn get_uid(&self) -> &Self::UIDType { - /// &self.name - /// } - /// } /// /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -154,13 +147,13 @@ impl Index { &self, query: &Query<'_>, ) -> Result, Error> { - Ok(request::<&Query, SearchResults>( + request::<&Query, SearchResults>( &format!("{}/indexes/{}/search", self.client.host, self.uid), &self.client.api_key, Method::Post(query), 200, ) - .await?) + .await } /// Search for documents matching a specific query in the index.\ @@ -170,20 +163,13 @@ impl Index { /// /// ``` /// use serde::{Serialize, Deserialize}; - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, search::*}; + /// # use meilisearch_sdk::{client::*, indexes::*, search::*}; /// /// #[derive(Serialize, Deserialize, Debug)] /// struct Movie { /// name: String, /// description: String, /// } - /// // that trait is used by the sdk when the primary key is needed - /// impl Document for Movie { - /// type UIDType = String; - /// fn get_uid(&self) -> &Self::UIDType { - /// &self.name - /// } - /// } /// /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -215,7 +201,7 @@ impl Index { /// ``` /// use serde::{Serialize, Deserialize}; /// - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// /// #[derive(Serialize, Deserialize, Debug)] /// # #[derive(PartialEq)] @@ -224,13 +210,6 @@ impl Index { /// description: String, /// } /// - /// // that trait is used by the sdk when the primary key is needed - /// impl Document for Movie { - /// type UIDType = String; - /// fn get_uid(&self) -> &Self::UIDType { - /// &self.name - /// } - /// } /// /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -238,7 +217,7 @@ impl Index { /// # movies.add_or_replace(&[Movie{name:String::from("Interstellar"), description:String::from("Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.")}], Some("name")).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); /// /// // retrieve a document (you have to put the document in the index before) - /// let interstellar = movies.get_document::(String::from("Interstellar")).await.unwrap(); + /// let interstellar = movies.get_document::("Interstellar").await.unwrap(); /// /// assert_eq!(interstellar, Movie { /// name: String::from("Interstellar"), @@ -247,8 +226,8 @@ impl Index { /// # movies.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); /// # }); /// ``` - pub async fn get_document(&self, uid: T::UIDType) -> Result { - Ok(request::<(), T>( + pub async fn get_document(&self, uid: &str) -> Result { + request::<(), T>( &format!( "{}/indexes/{}/documents/{}", self.client.host, self.uid, uid @@ -257,7 +236,7 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get [Document]s by batch. @@ -272,7 +251,7 @@ impl Index { /// ``` /// use serde::{Serialize, Deserialize}; /// - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// /// #[derive(Serialize, Deserialize, Debug)] /// # #[derive(PartialEq)] @@ -281,13 +260,6 @@ impl Index { /// description: String, /// } /// - /// // that trait is used by the sdk when the primary key is needed - /// impl Document for Movie { - /// type UIDType = String; - /// fn get_uid(&self) -> &Self::UIDType { - /// &self.name - /// } - /// } /// /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -302,7 +274,7 @@ impl Index { /// # movie_index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); /// # }); /// ``` - pub async fn get_documents( + pub async fn get_documents( &self, offset: Option, limit: Option, @@ -323,7 +295,7 @@ impl Index { url.push_str("attributesToRetrieve="); url.push_str(attributes_to_retrieve); } - Ok(request::<(), Vec>(&url, &self.client.api_key, Method::Get, 200).await?) + request::<(), Vec>(&url, &self.client.api_key, Method::Get, 200).await } /// Add a list of [Document]s or replace them if they already exist. @@ -340,7 +312,7 @@ impl Index { /// ``` /// use serde::{Serialize, Deserialize}; /// - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # use std::thread::sleep; /// # use std::time::Duration; /// #[derive(Serialize, Deserialize, Debug)] @@ -348,13 +320,6 @@ impl Index { /// name: String, /// description: String, /// } - /// // that trait is used by the sdk when the primary key is needed - /// impl Document for Movie { - /// type UIDType = String; - /// fn get_uid(&self) -> &Self::UIDType { - /// &self.name - /// } - /// } /// /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -383,7 +348,7 @@ impl Index { /// # movie_index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); /// # }); /// ``` - pub async fn add_or_replace( + pub async fn add_or_replace( &self, documents: &[T], primary_key: Option<&str>, @@ -396,11 +361,11 @@ impl Index { } else { format!("{}/indexes/{}/documents", self.client.host, self.uid) }; - Ok(request::<&[T], Task>(&url, &self.client.api_key, Method::Post(documents), 202).await?) + request::<&[T], Task>(&url, &self.client.api_key, Method::Post(documents), 202).await } /// Alias for [Index::add_or_replace]. - pub async fn add_documents( + pub async fn add_documents( &self, documents: &[T], primary_key: Option<&str>, @@ -420,7 +385,7 @@ impl Index { /// ``` /// use serde::{Serialize, Deserialize}; /// - /// # use meilisearch_sdk::{client::*, document::*}; + /// # use meilisearch_sdk::client::*; /// # use std::thread::sleep; /// # use std::time::Duration; /// #[derive(Serialize, Deserialize, Debug)] @@ -428,13 +393,6 @@ impl Index { /// name: String, /// description: String, /// } - /// // that trait is used by the sdk when the primary key is needed - /// impl Document for Movie { - /// type UIDType = String; - /// fn get_uid(&self) -> &Self::UIDType { - /// &self.name - /// } - /// } /// /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -464,7 +422,7 @@ impl Index { /// # movie_index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); /// # }); /// ``` - pub async fn add_or_update( + pub async fn add_or_update( &self, documents: &[T], primary_key: Option>, @@ -479,7 +437,7 @@ impl Index { } else { format!("{}/indexes/{}/documents", self.client.host, self.uid) }; - Ok(request::<&[T], Task>(&url, &self.client.api_key, Method::Put(documents), 202).await?) + request::<&[T], Task>(&url, &self.client.api_key, Method::Put(documents), 202).await } /// Delete all documents in the index. @@ -488,7 +446,7 @@ impl Index { /// /// ``` /// # use serde::{Serialize, Deserialize}; - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # /// # #[derive(Serialize, Deserialize, Debug)] /// # struct Movie { @@ -496,13 +454,6 @@ impl Index { /// # description: String, /// # } /// # - /// # // that trait is used by the sdk when the primary key is needed - /// # impl Document for Movie { - /// # type UIDType = String; - /// # fn get_uid(&self) -> &Self::UIDType { - /// # &self.name - /// # } - /// # } /// # /// # futures::executor::block_on(async move { /// # @@ -524,13 +475,13 @@ impl Index { /// # }); /// ``` pub async fn delete_all_documents(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!("{}/indexes/{}/documents", self.client.host, self.uid), &self.client.api_key, Method::Delete, 202, ) - .await?) + .await } /// Delete one document based on its unique id. @@ -539,7 +490,7 @@ impl Index { /// /// ``` /// # use serde::{Serialize, Deserialize}; - /// # use meilisearch_sdk::{client::*, document::*}; + /// # use meilisearch_sdk::client::*; /// # /// # #[derive(Serialize, Deserialize, Debug)] /// # struct Movie { @@ -547,13 +498,6 @@ impl Index { /// # description: String, /// # } /// # - /// # // that trait is used by the sdk when the primary key is needed - /// # impl Document for Movie { - /// # type UIDType = String; - /// # fn get_uid(&self) -> &Self::UIDType { - /// # &self.name - /// # } - /// # } /// # /// # futures::executor::block_on(async move { /// # @@ -573,7 +517,7 @@ impl Index { /// # }); /// ``` pub async fn delete_document(&self, uid: T) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/documents/{}", self.client.host, self.uid, uid @@ -582,7 +526,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Delete a selection of documents based on array of document id's. @@ -591,7 +535,7 @@ impl Index { /// /// ``` /// # use serde::{Serialize, Deserialize}; - /// # use meilisearch_sdk::{client::*, document::*}; + /// # use meilisearch_sdk::client::*; /// # /// # #[derive(Serialize, Deserialize, Debug)] /// # struct Movie { @@ -599,13 +543,6 @@ impl Index { /// # description: String, /// # } /// # - /// # // that trait is used by the sdk when the primary key is needed - /// # impl Document for Movie { - /// # type UIDType = String; - /// # fn get_uid(&self) -> &Self::UIDType { - /// # &self.name - /// # } - /// # } /// # /// # futures::executor::block_on(async move { /// # @@ -629,7 +566,7 @@ impl Index { &self, uids: &[T], ) -> Result { - Ok(request::<&[T], Task>( + request::<&[T], Task>( &format!( "{}/indexes/{}/documents/delete-batch", self.client.host, self.uid @@ -638,7 +575,7 @@ impl Index { Method::Post(uids), 202, ) - .await?) + .await } /// Alias for the [Index::update] method. @@ -665,13 +602,13 @@ impl Index { /// ``` /// If you use it directly from the [Client], you can use the method [Client::get_raw_index], which is the equivalent method from the client. pub async fn fetch_info(&self) -> Result { - Ok(request::<(), JsonIndex>( + request::<(), JsonIndex>( &format!("{}/indexes/{}", self.client.host, self.uid), &self.client.api_key, Method::Get, 200, ) - .await?) + .await } /// Fetch the primary key of the index. @@ -703,7 +640,7 @@ impl Index { /// # use serde::{Serialize, Deserialize}; /// # use std::thread::sleep; /// # use std::time::Duration; - /// # use meilisearch_sdk::{client::*, document, indexes::*, tasks::Task}; + /// # use meilisearch_sdk::{client::*, indexes::*, tasks::Task}; /// # /// # #[derive(Debug, Serialize, Deserialize, PartialEq)] /// # struct Document { @@ -712,13 +649,6 @@ impl Index { /// # kind: String, /// # } /// # - /// # impl document::Document for Document { - /// # type UIDType = usize; - /// # - /// # fn get_uid(&self) -> &Self::UIDType { - /// # &self.id - /// # } - /// # } /// # /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -764,7 +694,7 @@ impl Index { /// /// ``` /// # use serde::{Serialize, Deserialize}; - /// # use meilisearch_sdk::{client::*, document, indexes::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # /// # futures::executor::block_on(async move { /// # let client = Client::new("http://localhost:7700", "masterKey"); @@ -834,7 +764,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, document, indexes::*, tasks::Task}; + /// # use meilisearch_sdk::{client::*, indexes::*, tasks::Task}; /// # use serde::{Serialize, Deserialize}; /// # /// # #[derive(Debug, Serialize, Deserialize, PartialEq)] @@ -844,13 +774,6 @@ impl Index { /// # kind: String, /// # } /// # - /// # impl document::Document for Document { - /// # type UIDType = usize; - /// # - /// # fn get_uid(&self) -> &Self::UIDType { - /// # &self.id - /// # } - /// # } /// # /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); diff --git a/src/lib.rs b/src/lib.rs index 49817d91..e8b1b0a2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! ### Add Documents //! //! ```rust -//! use meilisearch_sdk::{document::*, client::*}; +//! use meilisearch_sdk::client::*; //! use serde::{Serialize, Deserialize}; //! use futures::executor::block_on; //! @@ -14,14 +14,6 @@ //! genres: Vec, //! } //! -//! // That trait is required to make a struct usable by an index -//! impl Document for Movie { -//! type UIDType = usize; -//! -//! fn get_uid(&self) -> &Self::UIDType { -//! &self.id -//! } -//! } //! //! fn main() { block_on(async move { //! // Create a client (without sending any request so that can't fail) @@ -49,7 +41,7 @@ //! ### Basic Search //! //! ```rust -//! # use meilisearch_sdk::{document::*, client::*}; +//! # use meilisearch_sdk::client::*; //! # use serde::{Serialize, Deserialize}; //! # use futures::executor::block_on; //! # #[derive(Serialize, Deserialize, Debug)] @@ -58,12 +50,6 @@ //! # title: String, //! # genres: Vec, //! # } -//! # impl Document for Movie { -//! # type UIDType = usize; -//! # fn get_uid(&self) -> &Self::UIDType { -//! # &self.id -//! # } -//! # } //! # fn main() { block_on(async move { //! # let client = Client::new("http://localhost:7700", "masterKey"); //! # let movies = client.create_index("movies_2", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap().try_make_index(&client).unwrap(); @@ -96,7 +82,7 @@ //! ### Custom Search //! //! ```rust -//! # use meilisearch_sdk::{document::*, client::*, search::*}; +//! # use meilisearch_sdk::{client::*, search::*}; //! # use serde::{Serialize, Deserialize}; //! # use futures::executor::block_on; //! # #[derive(Serialize, Deserialize, Debug)] @@ -105,12 +91,6 @@ //! # title: String, //! # genres: Vec, //! # } -//! # impl Document for Movie { -//! # type UIDType = usize; -//! # fn get_uid(&self) -> &Self::UIDType { -//! # &self.id -//! # } -//! # } //! # fn main() { block_on(async move { //! # let client = Client::new("http://localhost:7700", "masterKey"); //! # let movies = client.create_index("movies_3", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap().try_make_index(&client).unwrap(); @@ -175,7 +155,7 @@ //! Then, you can perform the search: //! //! ``` -//! # use meilisearch_sdk::{document::*, client::*, search::*}; +//! # use meilisearch_sdk::{client::*, search::*}; //! # use serde::{Serialize, Deserialize}; //! # use futures::executor::block_on; //! # #[derive(Serialize, Deserialize, Debug)] @@ -184,12 +164,6 @@ //! # title: String, //! # genres: Vec, //! # } -//! # impl Document for Movie { -//! # type UIDType = usize; -//! # fn get_uid(&self) -> &Self::UIDType { -//! # &self.id -//! # } -//! # } //! # fn main() { block_on(async move { //! # let client = Client::new("http://localhost:7700", "masterKey"); //! # let movies = client.create_index("movies_5", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap().try_make_index(&client).unwrap(); @@ -242,7 +216,6 @@ /// Module containing the [client::Client] struct. pub mod client; /// Module containing the [document::Document] trait. -pub mod document; pub mod dumps; /// Module containing the [errors::Error] struct. pub mod errors; diff --git a/src/search.rs b/src/search.rs index 32c9567c..301cbe29 100644 --- a/src/search.rs +++ b/src/search.rs @@ -280,7 +280,7 @@ impl<'a> Query<'a> { #[cfg(test)] mod tests { - use crate::{client::*, document, search::*}; + use crate::{client::*, search::*}; use meilisearch_test_macro::meilisearch_test; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; @@ -292,14 +292,6 @@ mod tests { kind: String, } - impl document::Document for Document { - type UIDType = usize; - - fn get_uid(&self) -> &Self::UIDType { - &self.id - } - } - impl PartialEq> for Document { fn eq(&self, rhs: &Map) -> bool { self.id.to_string() == rhs["id"] diff --git a/src/settings.rs b/src/settings.rs index 2781fbb1..0344d021 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -199,7 +199,7 @@ impl Index { /// Get [Settings] of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_settings", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -209,19 +209,19 @@ impl Index { /// # }); /// ``` pub async fn get_settings(&self) -> Result { - Ok(request::<(), Settings>( + request::<(), Settings>( &format!("{}/indexes/{}/settings", self.client.host, self.uid), &self.client.api_key, Method::Get, 200, ) - .await?) + .await } /// Get [synonyms](https://docs.meilisearch.com/reference/features/synonyms.html) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_synonyms", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -231,7 +231,7 @@ impl Index { /// # }); /// ``` pub async fn get_synonyms(&self) -> Result>, Error> { - Ok(request::<(), HashMap>>( + request::<(), HashMap>>( &format!( "{}/indexes/{}/settings/synonyms", self.client.host, self.uid @@ -240,13 +240,13 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get [stop-words](https://docs.meilisearch.com/reference/features/stop_words.html) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_stop_words", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -256,7 +256,7 @@ impl Index { /// # }); /// ``` pub async fn get_stop_words(&self) -> Result, Error> { - Ok(request::<(), Vec>( + request::<(), Vec>( &format!( "{}/indexes/{}/settings/stop-words", self.client.host, self.uid @@ -265,13 +265,13 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get [ranking rules](https://docs.meilisearch.com/learn/core_concepts/relevancy.html#ranking-rules) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_ranking_rules", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -281,7 +281,7 @@ impl Index { /// # }); /// ``` pub async fn get_ranking_rules(&self) -> Result, Error> { - Ok(request::<(), Vec>( + request::<(), Vec>( &format!( "{}/indexes/{}/settings/ranking-rules", self.client.host, self.uid @@ -290,13 +290,13 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get [filterable attributes](https://docs.meilisearch.com/reference/features/filtering_and_faceted_search.html) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_filterable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -306,7 +306,7 @@ impl Index { /// # }); /// ``` pub async fn get_filterable_attributes(&self) -> Result, Error> { - Ok(request::<(), Vec>( + request::<(), Vec>( &format!( "{}/indexes/{}/settings/filterable-attributes", self.client.host, self.uid @@ -315,13 +315,13 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get [sortable attributes](https://docs.meilisearch.com/reference/features/sorting.html) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_sortable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -331,7 +331,7 @@ impl Index { /// # }); /// ``` pub async fn get_sortable_attributes(&self) -> Result, Error> { - Ok(request::<(), Vec>( + request::<(), Vec>( &format!( "{}/indexes/{}/settings/sortable-attributes", self.client.host, self.uid @@ -340,13 +340,13 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get the [distinct attribute](https://docs.meilisearch.com/reference/features/settings.html#distinct-attribute) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_distinct_attribute", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -356,7 +356,7 @@ impl Index { /// # }); /// ``` pub async fn get_distinct_attribute(&self) -> Result, Error> { - Ok(request::<(), Option>( + request::<(), Option>( &format!( "{}/indexes/{}/settings/distinct-attribute", self.client.host, self.uid @@ -365,13 +365,13 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get [searchable attributes](https://docs.meilisearch.com/reference/features/field_properties.html#searchable-fields) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_searchable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -381,7 +381,7 @@ impl Index { /// # }); /// ``` pub async fn get_searchable_attributes(&self) -> Result, Error> { - Ok(request::<(), Vec>( + request::<(), Vec>( &format!( "{}/indexes/{}/settings/searchable-attributes", self.client.host, self.uid @@ -390,13 +390,13 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Get [displayed attributes](https://docs.meilisearch.com/reference/features/settings.html#displayed-attributes) of the [Index]. /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*}; + /// # use meilisearch_sdk::{client::*, indexes::*}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("get_displayed_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -406,7 +406,7 @@ impl Index { /// # }); /// ``` pub async fn get_displayed_attributes(&self) -> Result, Error> { - Ok(request::<(), Vec>( + request::<(), Vec>( &format!( "{}/indexes/{}/settings/displayed-attributes", self.client.host, self.uid @@ -415,7 +415,7 @@ impl Index { Method::Get, 200, ) - .await?) + .await } /// Update [settings](../settings/struct.Settings.html) of the [Index]. @@ -424,7 +424,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_settings", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -439,13 +439,13 @@ impl Index { /// # }); /// ``` pub async fn set_settings(&self, settings: &Settings) -> Result { - Ok(request::<&Settings, Task>( + request::<&Settings, Task>( &format!("{}/indexes/{}/settings", self.client.host, self.uid), &self.client.api_key, Method::Post(settings), 202, ) - .await?) + .await } /// Update [synonyms](https://docs.meilisearch.com/reference/features/synonyms.html) of the [Index]. @@ -453,7 +453,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_synonyms", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -472,7 +472,7 @@ impl Index { &self, synonyms: &HashMap>, ) -> Result { - Ok(request::<&HashMap>, Task>( + request::<&HashMap>, Task>( &format!( "{}/indexes/{}/settings/synonyms", self.client.host, self.uid @@ -481,7 +481,7 @@ impl Index { Method::Post(synonyms), 202, ) - .await?) + .await } /// Update [stop-words](https://docs.meilisearch.com/reference/features/stop_words.html) of the [Index]. @@ -489,7 +489,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_stop_words", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -504,7 +504,7 @@ impl Index { &self, stop_words: impl IntoIterator>, ) -> Result { - Ok(request::, Task>( + request::, Task>( &format!( "{}/indexes/{}/settings/stop-words", self.client.host, self.uid @@ -518,7 +518,7 @@ impl Index { ), 202, ) - .await?) + .await } /// Update [ranking rules](https://docs.meilisearch.com/learn/core_concepts/relevancy.html#ranking-rules) of the [Index]. @@ -526,7 +526,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_ranking_rules", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -550,7 +550,7 @@ impl Index { &self, ranking_rules: impl IntoIterator>, ) -> Result { - Ok(request::, Task>( + request::, Task>( &format!( "{}/indexes/{}/settings/ranking-rules", self.client.host, self.uid @@ -564,7 +564,7 @@ impl Index { ), 202, ) - .await?) + .await } /// Update [filterable attributes](https://docs.meilisearch.com/reference/features/filtering_and_faceted_search.html) of the [Index]. @@ -572,7 +572,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_filterable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -587,7 +587,7 @@ impl Index { &self, filterable_attributes: impl IntoIterator>, ) -> Result { - Ok(request::, Task>( + request::, Task>( &format!( "{}/indexes/{}/settings/filterable-attributes", self.client.host, self.uid @@ -601,7 +601,7 @@ impl Index { ), 202, ) - .await?) + .await } /// Update [sortable attributes](https://docs.meilisearch.com/reference/features/sorting.html) of the [Index]. @@ -609,7 +609,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_sortable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -624,7 +624,7 @@ impl Index { &self, sortable_attributes: impl IntoIterator>, ) -> Result { - Ok(request::, Task>( + request::, Task>( &format!( "{}/indexes/{}/settings/sortable-attributes", self.client.host, self.uid @@ -638,7 +638,7 @@ impl Index { ), 202, ) - .await?) + .await } /// Update the [distinct attribute](https://docs.meilisearch.com/reference/features/settings.html#distinct-attribute) of the [Index]. @@ -646,7 +646,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_distinct_attribute", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -660,7 +660,7 @@ impl Index { &self, distinct_attribute: impl AsRef, ) -> Result { - Ok(request::( + request::( &format!( "{}/indexes/{}/settings/distinct-attribute", self.client.host, self.uid @@ -669,7 +669,7 @@ impl Index { Method::Post(distinct_attribute.as_ref().to_string()), 202, ) - .await?) + .await } /// Update [searchable attributes](https://docs.meilisearch.com/reference/features/field_properties.html#searchable-fields) of the [Index]. @@ -677,7 +677,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_searchable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -691,7 +691,7 @@ impl Index { &self, searchable_attributes: impl IntoIterator>, ) -> Result { - Ok(request::, Task>( + request::, Task>( &format!( "{}/indexes/{}/settings/searchable-attributes", self.client.host, self.uid @@ -705,7 +705,7 @@ impl Index { ), 202, ) - .await?) + .await } /// Update [displayed attributes](https://docs.meilisearch.com/reference/features/settings.html#displayed-attributes) of the [Index]. @@ -713,7 +713,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("set_displayed_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -727,7 +727,7 @@ impl Index { &self, displayed_attributes: impl IntoIterator>, ) -> Result { - Ok(request::, Task>( + request::, Task>( &format!( "{}/indexes/{}/settings/displayed-attributes", self.client.host, self.uid @@ -741,7 +741,7 @@ impl Index { ), 202, ) - .await?) + .await } /// Reset [Settings] of the [Index]. @@ -750,7 +750,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_settings", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -761,13 +761,13 @@ impl Index { /// # }); /// ``` pub async fn reset_settings(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!("{}/indexes/{}/settings", self.client.host, self.uid), &self.client.api_key, Method::Delete, 202, ) - .await?) + .await } /// Reset [synonyms](https://docs.meilisearch.com/reference/features/synonyms.html) of the [Index]. @@ -775,7 +775,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_synonyms", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -786,7 +786,7 @@ impl Index { /// # }); /// ``` pub async fn reset_synonyms(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/synonyms", self.client.host, self.uid @@ -795,7 +795,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Reset [stop-words](https://docs.meilisearch.com/reference/features/stop_words.html) of the [Index]. @@ -803,7 +803,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_stop_words", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -814,7 +814,7 @@ impl Index { /// # }); /// ``` pub async fn reset_stop_words(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/stop-words", self.client.host, self.uid @@ -823,7 +823,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Reset [ranking rules](https://docs.meilisearch.com/learn/core_concepts/relevancy.html#ranking-rules) of the [Index] to default value. @@ -832,7 +832,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_ranking_rules", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -843,7 +843,7 @@ impl Index { /// # }); /// ``` pub async fn reset_ranking_rules(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/ranking-rules", self.client.host, self.uid @@ -852,7 +852,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Reset [filterable attributes](https://docs.meilisearch.com/reference/features/filtering_and_faceted_search.html) of the [Index]. @@ -860,7 +860,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_filterable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -871,7 +871,7 @@ impl Index { /// # }); /// ``` pub async fn reset_filterable_attributes(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/filterable-attributes", self.client.host, self.uid @@ -880,7 +880,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Reset [sortable attributes](https://docs.meilisearch.com/reference/features/sorting.html) of the [Index]. @@ -888,7 +888,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_sortable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -899,7 +899,7 @@ impl Index { /// # }); /// ``` pub async fn reset_sortable_attributes(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/sortable-attributes", self.client.host, self.uid @@ -908,7 +908,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Reset the [distinct attribute](https://docs.meilisearch.com/reference/features/settings.html#distinct-attribute) of the [Index]. @@ -916,7 +916,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_distinct_attribute", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -927,7 +927,7 @@ impl Index { /// # }); /// ``` pub async fn reset_distinct_attribute(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/distinct-attribute", self.client.host, self.uid @@ -936,7 +936,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Reset [searchable attributes](https://docs.meilisearch.com/reference/features/field_properties.html#searchable-fields) of the [Index] (enable all attributes). @@ -944,7 +944,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_searchable_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -955,7 +955,7 @@ impl Index { /// # }); /// ``` pub async fn reset_searchable_attributes(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/searchable-attributes", self.client.host, self.uid @@ -964,7 +964,7 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } /// Reset [displayed attributes](https://docs.meilisearch.com/reference/features/settings.html#displayed-attributes) of the [Index] (enable all attributes). @@ -972,7 +972,7 @@ impl Index { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, indexes::*, document::*, settings::Settings}; + /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings}; /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); /// # client.create_index("reset_displayed_attributes", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); @@ -983,7 +983,7 @@ impl Index { /// # }); /// ``` pub async fn reset_displayed_attributes(&self) -> Result { - Ok(request::<(), Task>( + request::<(), Task>( &format!( "{}/indexes/{}/settings/displayed-attributes", self.client.host, self.uid @@ -992,6 +992,6 @@ impl Index { Method::Delete, 202, ) - .await?) + .await } } diff --git a/src/tasks.rs b/src/tasks.rs index e49149d8..9c333f1c 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -149,7 +149,7 @@ impl Task { /// # Example /// /// ``` - /// # use meilisearch_sdk::{client::*, document, indexes::*, tasks::Task}; + /// # use meilisearch_sdk::{client::*, indexes::*, tasks::Task}; /// # use serde::{Serialize, Deserialize}; /// # /// # #[derive(Debug, Serialize, Deserialize, PartialEq)] @@ -159,13 +159,6 @@ impl Task { /// # kind: String, /// # } /// # - /// # impl document::Document for Document { - /// # type UIDType = usize; - /// # - /// # fn get_uid(&self) -> &Self::UIDType { - /// # &self.id - /// # } - /// # } /// # /// # futures::executor::block_on(async move { /// let client = Client::new("http://localhost:7700", "masterKey"); @@ -384,7 +377,6 @@ mod test { use super::*; use crate::{ client::*, - document, errors::{ErrorCode, ErrorType}, }; use meilisearch_test_macro::meilisearch_test; @@ -398,14 +390,6 @@ mod test { kind: String, } - impl document::Document for Document { - type UIDType = usize; - - fn get_uid(&self) -> &Self::UIDType { - &self.id - } - } - #[test] fn test_deserialize_task() { let datetime = OffsetDateTime::parse(