diff --git a/examples/settings.rs b/examples/settings.rs index 64952697..11f6d0f1 100644 --- a/examples/settings.rs +++ b/examples/settings.rs @@ -39,12 +39,11 @@ async fn main() { .expect("Could not join the remote server."); // We check if the task failed. - if task.is_failure() { - panic!( - "Could not update the settings. {}", - task.unwrap_failure().error_message - ); - } + assert!( + !task.is_failure(), + "Could not update the settings. {}", + task.unwrap_failure().error_message + ); // And finally we delete the `Index`. my_index @@ -56,10 +55,9 @@ async fn main() { .expect("Could not join the remote server."); // We check if the task failed. - if task.is_failure() { - panic!( - "Could not delete the index. {}", - task.unwrap_failure().error_message - ); - } + assert!( + !task.is_failure(), + "Could not delete the index. {}", + task.unwrap_failure().error_message + ); } diff --git a/examples/web_app/src/lib.rs b/examples/web_app/src/lib.rs index 8d5a1e87..99e1de65 100644 --- a/examples/web_app/src/lib.rs +++ b/examples/web_app/src/lib.rs @@ -44,7 +44,7 @@ impl Component for Model { type Message = Msg; type Properties = (); fn create(_ctx: &Context) -> Model { - Self { + Model { // The index method avoids checking the existence of the index. // It won't make any HTTP request so the function is not async so it's easier to use. // Use only if you are sure that the index exists. diff --git a/src/client.rs b/src/client.rs index 8231ba0c..9f625166 100644 --- a/src/client.rs +++ b/src/client.rs @@ -46,11 +46,11 @@ impl Client { pub fn new(host: impl Into, api_key: Option>) -> Client { Client { host: host.into(), - api_key: api_key.map(|key| key.into()), + api_key: api_key.map(std::convert::Into::into), } } - fn parse_indexes_results_from_value(&self, value: Value) -> Result { + fn parse_indexes_results_from_value(&self, value: &Value) -> Result { let raw_indexes = value["results"].as_array().unwrap(); let indexes_results = IndexesResults { @@ -174,7 +174,7 @@ impl Client { /// ``` pub async fn list_all_indexes(&self) -> Result { let value = self.list_all_indexes_raw().await?; - let indexes_results = self.parse_indexes_results_from_value(value)?; + let indexes_results = self.parse_indexes_results_from_value(&value)?; Ok(indexes_results) } @@ -203,7 +203,7 @@ impl Client { indexes_query: &IndexesQuery<'_>, ) -> Result { let value = self.list_all_indexes_raw_with(indexes_query).await?; - let indexes_results = self.parse_indexes_results_from_value(value)?; + let indexes_results = self.parse_indexes_results_from_value(&value)?; Ok(indexes_results) } @@ -301,7 +301,7 @@ impl Client { /// Get a raw JSON [Index], this index should already exist. /// - /// If you use it directly from an [Index], you can use the method [Index::fetch_info], which is the equivalent method from an index. + /// If you use it directly from an [Index], you can use the method [`Index::fetch_info`], which is the equivalent method from an index. /// /// # Example /// @@ -385,7 +385,7 @@ impl Client { /// Delete an index from its UID. /// - /// To delete an [Index], use the [Index::delete] method. + /// To delete an [Index], use the [`Index::delete`] method. pub async fn delete_index(&self, uid: impl AsRef) -> Result { request::<(), (), TaskInfo>( &format!("{}/indexes/{}", self.host, uid.as_ref()), @@ -396,12 +396,12 @@ impl Client { .await } - /// Alias for [Client::list_all_indexes]. + /// Alias for [`Client::list_all_indexes`]. pub async fn get_indexes(&self) -> Result { self.list_all_indexes().await } - /// Alias for [Client::list_all_indexes_with]. + /// Alias for [`Client::list_all_indexes_with`]. pub async fn get_indexes_with( &self, indexes_query: &IndexesQuery<'_>, @@ -409,12 +409,12 @@ impl Client { self.list_all_indexes_with(indexes_query).await } - /// Alias for [Client::list_all_indexes_raw]. + /// Alias for [`Client::list_all_indexes_raw`]. pub async fn get_indexes_raw(&self) -> Result { self.list_all_indexes_raw().await } - /// Alias for [Client::list_all_indexes_raw_with]. + /// Alias for [`Client::list_all_indexes_raw_with`]. pub async fn get_indexes_raw_with( &self, indexes_query: &IndexesQuery<'_>, @@ -549,7 +549,7 @@ impl Client { /// Get the API [Keys](Key) from Meilisearch with parameters. /// - /// See [Client::create_key], [Client::get_key], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#get-all-keys). + /// See [`Client::create_key`], [`Client::get_key`], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#get-all-keys). /// /// # Example /// @@ -583,7 +583,7 @@ impl Client { /// Get the API [Keys](Key) from Meilisearch. /// - /// See [Client::create_key], [Client::get_key], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#get-all-keys). + /// See [`Client::create_key`], [`Client::get_key`], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#get-all-keys). /// /// # Example /// @@ -614,7 +614,7 @@ impl Client { /// Get one API [Key] from Meilisearch. /// - /// See also [Client::create_key], [Client::get_keys], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#get-one-key). + /// See also [`Client::create_key`], [`Client::get_keys`], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#get-one-key). /// /// # Example /// @@ -646,7 +646,7 @@ impl Client { /// Delete an API [Key] from Meilisearch. /// - /// See also [Client::create_key], [Client::update_key], [Client::get_key], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#delete-a-key). + /// See also [`Client::create_key`], [`Client::update_key`], [`Client::get_key`], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#delete-a-key). /// /// # Example /// @@ -681,7 +681,7 @@ impl Client { /// Create an API [Key] in Meilisearch. /// - /// See also [Client::update_key], [Client::delete_key], [Client::get_key], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#create-a-key). + /// See also [`Client::update_key`], [`Client::delete_key`], [`Client::get_key`], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#create-a-key). /// /// # Example /// @@ -718,7 +718,7 @@ impl Client { /// Update an API [Key] in Meilisearch. /// - /// See also [Client::create_key], [Client::delete_key], [Client::get_key], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#update-a-key). + /// See also [`Client::create_key`], [`Client::delete_key`], [`Client::get_key`], and the [meilisearch documentation](https://docs.meilisearch.com/reference/api/keys.html#update-a-key). /// /// # Example /// @@ -787,9 +787,9 @@ impl Client { /// /// `timeout` = The maximum time to wait for processing to complete. **Default = 5000ms** /// - /// If the waited time exceeds `timeout` then an [Error::Timeout] will be returned. + /// If the waited time exceeds `timeout` then an [`Error::Timeout`] will be returned. /// - /// See also [Index::wait_for_task, Task::wait_for_completion, TaskInfo::wait_for_completion]. + /// See also [`Index::wait_for_task`, `Task::wait_for_completion`, `TaskInfo::wait_for_completion`]. /// /// # Example /// @@ -917,7 +917,7 @@ impl Client { Ok(tasks) } - /// Cancel tasks with filters [TasksCancelQuery]. + /// Cancel tasks with filters [`TasksCancelQuery`]. /// /// # Example /// @@ -953,7 +953,7 @@ impl Client { Ok(tasks) } - /// Delete tasks with filters [TasksDeleteQuery]. + /// Delete tasks with filters [`TasksDeleteQuery`]. /// /// # Example /// @@ -1054,7 +1054,7 @@ impl Client { } } -#[derive(Deserialize)] +#[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ClientStats { pub database_size: usize, @@ -1073,7 +1073,7 @@ pub struct ClientStats { /// status: "available".to_string(), /// }; /// ``` -#[derive(Deserialize)] +#[derive(Debug, Clone, Deserialize)] pub struct Health { pub status: String, } @@ -1090,7 +1090,7 @@ pub struct Health { /// pkg_version: "0.1.1".to_string(), /// }; /// ``` -#[derive(Deserialize)] +#[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Version { pub commit_sha: String, @@ -1331,7 +1331,7 @@ mod tests { let mut key = KeyBuilder::new(); key.with_action(Action::DocumentsAdd) .with_name(&name) - .with_expires_at(expires_at.clone()) + .with_expires_at(expires_at) .with_description("a description") .with_index("*"); let key = client.create_key(key).await.unwrap(); diff --git a/src/dumps.rs b/src/dumps.rs index 03274f84..d9791376 100644 --- a/src/dumps.rs +++ b/src/dumps.rs @@ -87,7 +87,7 @@ impl Client { } } -/// Alias for [create_dump](Client::create_dump). +/// Alias for [`create_dump`](Client::create_dump). pub async fn create_dump(client: &Client) -> Result { client.create_dump().await } diff --git a/src/indexes.rs b/src/indexes.rs index c80023f2..441dc5a8 100644 --- a/src/indexes.rs +++ b/src/indexes.rs @@ -16,7 +16,7 @@ use time::OffsetDateTime; /// # Example /// /// You can create an index remotly and, if that succeed, make an `Index` out of it. -/// See the [Client::create_index] method. +/// See the [`Client::create_index`] method. /// ``` /// # use meilisearch_sdk::{client::*, indexes::*}; /// # @@ -189,7 +189,7 @@ impl Index { /// Search for documents matching a specific query in the index. /// - /// See also [Index::search]. + /// See also [`Index::search`]. /// /// # Example /// @@ -234,7 +234,7 @@ impl Index { /// Search for documents matching a specific query in the index. /// - /// See also [Index::execute_query]. + /// See also [`Index::execute_query`]. /// /// # Example /// @@ -483,9 +483,9 @@ impl Index { /// If you send an already existing document (same id) the **whole existing document** will be overwritten by the new document. /// Fields previously in the document not present in the new document are removed. /// - /// For a partial update of the document see [Index::add_or_update]. + /// For a partial update of the document see [`Index::add_or_update`]. /// - /// You can use the alias [Index::add_documents] if you prefer. + /// You can use the alias [`Index::add_documents`] if you prefer. /// /// # Example /// @@ -563,7 +563,7 @@ impl Index { /// If you send an already existing document (same id) the **whole existing document** will be overwritten by the new document. /// Fields previously in the document not present in the new document are removed. /// - /// For a partial update of the document see [Index::add_or_update_unchecked_payload]. + /// For a partial update of the document see [`Index::add_or_update_unchecked_payload`]. /// /// # Example /// @@ -623,7 +623,7 @@ impl Index { .await } - /// Alias for [Index::add_or_replace]. + /// Alias for [`Index::add_or_replace`]. pub async fn add_documents( &self, documents: &[T], @@ -637,7 +637,7 @@ impl Index { /// If you send an already existing document (same id) the old document will be only partially updated according to the fields of the new document. /// Thus, any fields not present in the new document are kept and remained unchanged. /// - /// To completely overwrite a document, check out the [Index::add_or_replace] documents method. + /// To completely overwrite a document, check out the [`Index::add_or_replace`] documents method. /// /// # Example /// @@ -718,7 +718,7 @@ impl Index { /// If you send an already existing document (same id) the old document will be only partially updated according to the fields of the new document. /// Thus, any fields not present in the new document are kept and remained unchanged. /// - /// To completely overwrite a document, check out the [Index::add_or_replace_unchecked_payload] documents method. + /// To completely overwrite a document, check out the [`Index::add_or_replace_unchecked_payload`] documents method. /// /// # Example /// @@ -926,7 +926,7 @@ impl Index { .await } - /// Alias for the [Index::update] method. + /// Alias for the [`Index::update`] method. pub async fn set_primary_key( &mut self, primary_key: impl AsRef, @@ -938,7 +938,7 @@ impl Index { /// Fetch the information of the index as a raw JSON [Index], this index should already exist. /// - /// 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. + /// 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. /// /// # Example /// @@ -1145,9 +1145,9 @@ impl Index { /// /// `timeout` = The maximum time to wait for processing to complete. **Default = 5000ms** /// - /// If the waited time exceeds `timeout` then an [Error::Timeout] will be returned. + /// If the waited time exceeds `timeout` then an [`Error::Timeout`] will be returned. /// - /// See also [Client::wait_for_task, Task::wait_for_completion]. + /// See also [`Client::wait_for_task`, `Task::wait_for_completion`]. /// /// # Example /// @@ -1351,7 +1351,7 @@ impl AsRef for Index { } } -/// An [IndexUpdater] used to update the specifics of an index. +/// An [`IndexUpdater`] used to update the specifics of an index. /// /// # Example /// @@ -1404,7 +1404,7 @@ impl<'a> IndexUpdater<'a> { uid: uid.as_ref().to_string(), } } - /// Define the new primary_key to set on the [Index]. + /// Define the new `primary_key` to set on the [Index]. /// /// # Example /// @@ -1441,12 +1441,12 @@ impl<'a> IndexUpdater<'a> { /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap(); /// # }); /// ``` - pub fn with_primary_key(&mut self, primary_key: impl AsRef) -> &mut Self { + pub fn with_primary_key(&mut self, primary_key: impl AsRef) -> &mut IndexUpdater<'a> { self.primary_key = Some(primary_key.as_ref().to_string()); self } - /// Execute the update of an [Index] using the [IndexUpdater]. + /// Execute the update of an [Index] using the [`IndexUpdater`]. /// /// # Example /// @@ -1509,7 +1509,7 @@ impl<'a> AsRef> for IndexUpdater<'a> { } } -#[derive(Deserialize)] +#[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct IndexStats { pub number_of_documents: usize, @@ -1517,7 +1517,7 @@ pub struct IndexStats { pub field_distribution: HashMap, } -/// An [IndexesQuery] containing filter and pagination parameters when searching for [Indexes](Index). +/// An [`IndexesQuery`] containing filter and pagination parameters when searching for [Indexes](Index). /// /// # Example /// diff --git a/src/key.rs b/src/key.rs index de6a507f..b0905e87 100644 --- a/src/key.rs +++ b/src/key.rs @@ -5,7 +5,7 @@ use crate::{client::Client, errors::Error}; /// Represents a [meilisearch key](https://docs.meilisearch.com/reference/api/keys.html#returned-fields). /// -/// You can get a [Key] from the [Client::get_key] method, or you can create a [Key] with the [KeyBuilder::new] or [Client::create_key] methods. +/// You can get a [Key] from the [`Client::get_key`] method, or you can create a [Key] with the [`KeyBuilder::new`] or [`Client::create_key`] methods. #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct Key { @@ -51,7 +51,7 @@ impl Key { /// # client.delete_key(key).await.unwrap(); /// # }); /// ``` - pub fn with_description(&mut self, desc: impl AsRef) -> &mut Self { + pub fn with_description(&mut self, desc: impl AsRef) -> &mut Key { self.description = Some(desc.as_ref().to_string()); self } @@ -82,7 +82,7 @@ impl Key { /// # client.delete_key(key).await.unwrap(); /// # }); /// ``` - pub fn with_name(&mut self, desc: impl AsRef) -> &mut Self { + pub fn with_name(&mut self, desc: impl AsRef) -> &mut Key { self.name = Some(desc.as_ref().to_string()); self } @@ -208,7 +208,7 @@ impl KeyUpdater { /// # client.delete_key(key_update).await.unwrap(); /// # }); /// ``` - pub fn with_description(&mut self, desc: impl AsRef) -> &mut Self { + pub fn with_description(&mut self, desc: impl AsRef) -> &mut KeyUpdater { self.description = Some(desc.as_ref().to_string()); self } @@ -241,12 +241,12 @@ impl KeyUpdater { /// # client.delete_key(key_update).await.unwrap(); /// # }); /// ``` - pub fn with_name(&mut self, desc: impl AsRef) -> &mut Self { + pub fn with_name(&mut self, desc: impl AsRef) -> &mut KeyUpdater { self.name = Some(desc.as_ref().to_string()); self } - /// Update a [Key] using the [KeyUpdater]. + /// Update a [Key] using the [`KeyUpdater`]. /// /// # Example /// @@ -310,7 +310,7 @@ pub struct KeysQuery { } impl KeysQuery { - /// Create a [KeysQuery] with only a description. + /// Create a [`KeysQuery`] with only a description. /// /// # Example /// @@ -394,7 +394,7 @@ impl KeysQuery { } } -/// The [KeyBuilder] is an analog to the [Key] type but without all the fields managed by Meilisearch. +/// The [`KeyBuilder`] is an analog to the [Key] type but without all the fields managed by Meilisearch. /// /// It's used to create [Key]. /// @@ -417,7 +417,7 @@ impl KeysQuery { /// # client.delete_key(key).await.unwrap(); /// # }); /// ``` -#[derive(Debug, Serialize, Default)] +#[derive(Debug, Clone, Serialize, Default)] #[serde(rename_all = "camelCase")] pub struct KeyBuilder { pub actions: Vec, @@ -433,7 +433,7 @@ pub struct KeyBuilder { } impl KeyBuilder { - /// Create a [KeyBuilder]. + /// Create a [`KeyBuilder`]. /// /// # Example /// @@ -454,7 +454,7 @@ impl KeyBuilder { /// let mut builder = KeyBuilder::new(); /// builder.with_actions(vec![Action::Search, Action::DocumentsAdd]); /// ``` - pub fn with_actions(&mut self, actions: impl IntoIterator) -> &mut Self { + pub fn with_actions(&mut self, actions: impl IntoIterator) -> &mut KeyBuilder { self.actions.extend(actions); self } @@ -468,7 +468,7 @@ impl KeyBuilder { /// let mut builder = KeyBuilder::new(); /// builder.with_action(Action::DocumentsAdd); /// ``` - pub fn with_action(&mut self, action: Action) -> &mut Self { + pub fn with_action(&mut self, action: Action) -> &mut KeyBuilder { self.actions.push(action); self } @@ -484,7 +484,7 @@ impl KeyBuilder { /// // create a key that expires in two weeks from now /// builder.with_expires_at(OffsetDateTime::now_utc() + Duration::WEEK * 2); /// ``` - pub fn with_expires_at(&mut self, expires_at: OffsetDateTime) -> &mut Self { + pub fn with_expires_at(&mut self, expires_at: OffsetDateTime) -> &mut KeyBuilder { self.expires_at = Some(expires_at); self } @@ -514,7 +514,7 @@ impl KeyBuilder { pub fn with_indexes( &mut self, indexes: impl IntoIterator>, - ) -> &mut Self { + ) -> &mut KeyBuilder { self.indexes = indexes .into_iter() .map(|index| index.as_ref().to_string()) @@ -531,7 +531,7 @@ impl KeyBuilder { /// let mut builder = KeyBuilder::new(); /// builder.with_index("test"); /// ``` - pub fn with_index(&mut self, index: impl AsRef) -> &mut Self { + pub fn with_index(&mut self, index: impl AsRef) -> &mut KeyBuilder { self.indexes.push(index.as_ref().to_string()); self } @@ -557,7 +557,7 @@ impl KeyBuilder { /// # client.delete_key(key).await.unwrap(); /// # }); /// ``` - pub fn with_description(&mut self, desc: impl AsRef) -> &mut Self { + pub fn with_description(&mut self, desc: impl AsRef) -> &mut KeyBuilder { self.description = Some(desc.as_ref().to_string()); self } @@ -583,7 +583,7 @@ impl KeyBuilder { /// # client.delete_key(key).await.unwrap(); /// # }); /// ``` - pub fn with_name(&mut self, desc: impl AsRef) -> &mut Self { + pub fn with_name(&mut self, desc: impl AsRef) -> &mut KeyBuilder { self.name = Some(desc.as_ref().to_string()); self } @@ -609,7 +609,7 @@ impl KeyBuilder { /// # client.delete_key(key).await.unwrap(); /// # }); /// ``` - pub fn with_uid(&mut self, desc: impl AsRef) -> &mut Self { + pub fn with_uid(&mut self, desc: impl AsRef) -> &mut KeyBuilder { self.uid = Some(desc.as_ref().to_string()); self } diff --git a/src/lib.rs b/src/lib.rs index 4087068b..3cfed4c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -223,26 +223,26 @@ #![warn(clippy::all)] #![allow(clippy::needless_doctest_main)] -/// Module containing the [client::Client] struct. +/// Module containing the [`client::Client`] struct. pub mod client; /// Module representing the [documents] structures. pub mod documents; /// Module containing the [dumps] trait. pub mod dumps; -/// Module containing the [errors::Error] struct. +/// Module containing the [`errors::Error`] struct. pub mod errors; /// Module containing the Index struct. pub mod indexes; -/// Module containing the [key::Key] struct. +/// Module containing the [`key::Key`] struct. pub mod key; mod request; /// Module related to search queries and results. pub mod search; -/// Module containing [settings::Settings]. +/// Module containing [`settings::Settings`]. pub mod settings; -/// Module representing the [task_info::TaskInfo]s. +/// Module representing the [`task_info::TaskInfo`]s. pub mod task_info; -/// Module representing the [tasks::Task]s. +/// Module representing the [`tasks::Task`]s. pub mod tasks; /// Module that generates tenant tokens. mod tenant_tokens; diff --git a/src/request.rs b/src/request.rs index 6015e437..2a6e474b 100644 --- a/src/request.rs +++ b/src/request.rs @@ -116,7 +116,7 @@ pub(crate) async fn request< body = "null".to_string(); } - parse_response(status, expected_status_code, body) + parse_response(status, expected_status_code, &body) } #[cfg(not(target_arch = "wasm32"))] @@ -214,7 +214,7 @@ pub(crate) async fn stream_request< body = "null".to_string(); } - parse_response(status, expected_status_code, body) + parse_response(status, expected_status_code, &body) } #[cfg(target_arch = "wasm32")] @@ -318,9 +318,9 @@ pub(crate) async fn request< if let Some(t) = text.as_string() { if t.is_empty() { - parse_response(status, expected_status_code, String::from("null")) + parse_response(status, expected_status_code, "null") } else { - parse_response(status, expected_status_code, t) + parse_response(status, expected_status_code, &t) } } else { error!("Invalid response"); @@ -331,10 +331,10 @@ pub(crate) async fn request< fn parse_response( status_code: u16, expected_status_code: u16, - body: String, + body: &str, ) -> Result { if status_code == expected_status_code { - match from_str::(&body) { + match from_str::(body) { Ok(output) => { trace!("Request succeed"); return Ok(output); @@ -352,7 +352,7 @@ fn parse_response( "Expected response code {}, got {}", expected_status_code, status_code ); - match from_str::(&body) { + match from_str::(body) { Ok(e) => Err(Error::from(e)), Err(e) => Err(Error::ParseError(e)), } diff --git a/src/search.rs b/src/search.rs index aaa90fb8..0f44f0bc 100644 --- a/src/search.rs +++ b/src/search.rs @@ -47,13 +47,13 @@ pub struct SearchResult { pub matches_position: Option>>, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] pub struct FacetStats { pub min: u32, pub max: u32, } -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase")] /// A struct containing search results and other information about the search. pub struct SearchResults { @@ -106,8 +106,7 @@ fn serialize_attributes_to_crop_with_wildcard( let results = data .iter() .map(|(name, value)| { - let mut result = String::new(); - result.push_str(name); + let mut result = name.to_string(); if let Some(value) = value { result.push(':'); result.push_str(value.to_string().as_str()); @@ -115,7 +114,6 @@ fn serialize_attributes_to_crop_with_wildcard( result }) .collect::>(); - results.serialize(s) } None => s.serialize_none(), @@ -536,7 +534,7 @@ impl<'a, 'b> MultiSearchQuery<'a, 'b> { self.client.execute_multi_search_query::(self).await } } -#[derive(Debug, Deserialize)] +#[derive(Debug, Clone, Deserialize)] pub struct MultiSearchResponse { pub results: Vec>, } diff --git a/src/settings.rs b/src/settings.rs index 8ba35cfa..ab0ea97b 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -13,7 +13,7 @@ pub struct PaginationSetting { pub max_total_hits: usize, } -#[derive(Serialize, Deserialize, Default, Debug, Clone, Eq, PartialEq)] +#[derive(Serialize, Deserialize, Default, Debug, Clone, Eq, PartialEq, Copy)] #[serde(rename_all = "camelCase")] pub struct FacetingSettings { pub max_values_per_facet: usize, @@ -96,6 +96,7 @@ impl Settings { faceting: None, } } + pub fn with_synonyms(self, synonyms: HashMap) -> Settings where S: AsRef, @@ -224,7 +225,7 @@ impl Settings { pub fn with_faceting(self, faceting: &FacetingSettings) -> Settings { Settings { - faceting: Some(faceting.clone()), + faceting: Some(*faceting), ..self } } diff --git a/src/task_info.rs b/src/task_info.rs index 28f79f34..a864b9c2 100644 --- a/src/task_info.rs +++ b/src/task_info.rs @@ -27,15 +27,15 @@ impl TaskInfo { self.task_uid } - /// Wait until Meilisearch processes a task provided by [TaskInfo], and get its status. + /// Wait until Meilisearch processes a task provided by [`TaskInfo`], and get its status. /// /// `interval` = The frequency at which the server should be polled. **Default = 50ms** /// /// `timeout` = The maximum time to wait for processing to complete. **Default = 5000ms** /// - /// If the waited time exceeds `timeout` then an [Error::Timeout] will be returned. + /// If the waited time exceeds `timeout` then an [`Error::Timeout`] will be returned. /// - /// See also [Client::wait_for_task, Index::wait_for_task]. + /// See also [`Client::wait_for_task`, `Index::wait_for_task`]. /// /// # Example /// diff --git a/src/tasks.rs b/src/tasks.rs index 95509609..21a816f7 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -219,9 +219,9 @@ impl Task { /// /// `timeout` = The maximum time to wait for processing to complete. **Default = 5000ms** /// - /// If the waited time exceeds `timeout` then an [Error::Timeout] will be returned. + /// If the waited time exceeds `timeout` then an [`Error::Timeout`] will be returned. /// - /// See also [Client::wait_for_task, Index::wait_for_task]. + /// See also [`Client::wait_for_task`, `Index::wait_for_task`]. /// /// # Example /// @@ -305,9 +305,9 @@ impl Task { } } - /// Unwrap the [MeilisearchError] from a [Self::Failed] [Task]. + /// Unwrap the [`MeilisearchError`] from a [`Self::Failed`] [Task]. /// - /// Will panic if the task was not [Self::Failed]. + /// Will panic if the task was not [`Self::Failed`]. /// /// # Example /// @@ -345,7 +345,7 @@ impl Task { } } - /// Returns `true` if the [Task] is [Self::Failed]. + /// Returns `true` if the [Task] is [`Self::Failed`]. /// /// # Example /// @@ -375,7 +375,7 @@ impl Task { matches!(self, Self::Failed { .. }) } - /// Returns `true` if the [Task] is [Self::Succeeded]. + /// Returns `true` if the [Task] is [`Self::Succeeded`]. /// /// # Example /// @@ -403,7 +403,7 @@ impl Task { matches!(self, Self::Succeeded { .. }) } - /// Returns `true` if the [Task] is pending ([Self::Enqueued] or [Self::Processing]). + /// Returns `true` if the [Task] is pending ([`Self::Enqueued`] or [`Self::Processing`]). /// /// # Example /// ```no_run diff --git a/src/tenant_tokens.rs b/src/tenant_tokens.rs index 747fae8b..ea9bab98 100644 --- a/src/tenant_tokens.rs +++ b/src/tenant_tokens.rs @@ -94,7 +94,7 @@ mod tests { fn test_generate_token_without_uid() { let api_key_uid = S(""); let key = S(""); - let token = generate_tenant_token(api_key_uid, json!(SEARCH_RULES), &key, None); + let token = generate_tenant_token(api_key_uid, json!(SEARCH_RULES), key, None); assert!(token.is_err()); } @@ -163,7 +163,7 @@ mod tests { fn test_generate_token_with_wrongly_formated_uid() { let api_key_uid = S("xxx"); let key = "Ëa1ทt9bVcL-vãUทtP3OpXW5qPc%bWH5ทvw09"; - let token = generate_tenant_token(api_key_uid.clone(), json!(SEARCH_RULES), key, None); + let token = generate_tenant_token(api_key_uid, json!(SEARCH_RULES), key, None); assert!(token.is_err()); } @@ -172,7 +172,7 @@ mod tests { fn test_generate_token_with_wrong_uid_version() { let api_key_uid = S("6a11eb96-2485-11ed-861d-0242ac120002"); let key = "Ëa1ทt9bVcL-vãUทtP3OpXW5qPc%bWH5ทvw09"; - let token = generate_tenant_token(api_key_uid.clone(), json!(SEARCH_RULES), key, None); + let token = generate_tenant_token(api_key_uid, json!(SEARCH_RULES), key, None); assert!(token.is_err()); }