Skip to content

Commit

Permalink
Merge #493
Browse files Browse the repository at this point in the history
493: Re-export public structures for better import path r=bidoubiwa a=adriantombu

# Pull Request

## Related issue
Fixes #246

## What does this PR do?
- I think the PR title is already self-explanatory 😄

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Adrian Tombu <[email protected]>
  • Loading branch information
meili-bors[bot] and adriantombu authored Jul 18, 2023
2 parents 4aa3fc9 + c092bda commit 039ad9d
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 114 deletions.
2 changes: 1 addition & 1 deletion examples/cli-app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use futures::executor::block_on;
use lazy_static::lazy_static;
use meilisearch_sdk::{client::*, settings::Settings};
use meilisearch_sdk::{client::*, Settings};
use serde::{Deserialize, Serialize};
use std::fmt;
use std::io::stdin;
Expand Down
4 changes: 1 addition & 3 deletions examples/settings.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use meilisearch_sdk::client::Client;
use meilisearch_sdk::indexes::Index;
use meilisearch_sdk::settings::Settings;
use meilisearch_sdk::{Client, Index, Settings};

// we need an async runtime
#[tokio::main(flavor = "current_thread")]
Expand Down
6 changes: 1 addition & 5 deletions examples/web_app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#![recursion_limit = "512"]
use lazy_static::lazy_static;
use meilisearch_sdk::{
client::Client,
indexes::Index,
search::{SearchResults, Selectors::All},
};
use meilisearch_sdk::{Client, Index, SearchResults, Selectors::All};
use serde_json::{Map, Value};
use std::rc::Rc;
use wasm_bindgen::prelude::*;
Expand Down
33 changes: 12 additions & 21 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ use std::{collections::HashMap, time::Duration};
use time::OffsetDateTime;

use crate::{
errors::*,
indexes::*,
key::{Key, KeyBuilder, KeyUpdater, KeysQuery, KeysResults},
request::*,
search::*,
task_info::TaskInfo,
tasks::{Task, TasksCancelQuery, TasksDeleteQuery, TasksResults, TasksSearchQuery},
utils::async_sleep,
errors::*, indexes::*, request::*, search::*, utils::async_sleep, Key, KeyBuilder, KeyUpdater,
KeysQuery, KeysResults, Task, TaskInfo, TasksCancelQuery, TasksDeleteQuery, TasksResults,
TasksSearchQuery,
};

/// The top-level struct of the SDK, representing a client containing [indexes](../indexes/struct.Index.html).
Expand Down Expand Up @@ -500,7 +495,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, errors::{Error, ErrorCode}};
/// # use meilisearch_sdk::{client::*, Error, ErrorCode};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down Expand Up @@ -554,7 +549,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, errors::Error, key::KeysQuery};
/// # use meilisearch_sdk::{client::*, Error, KeysQuery};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down Expand Up @@ -588,7 +583,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, errors::Error, key::KeyBuilder};
/// # use meilisearch_sdk::{client::*, Error, KeyBuilder};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down Expand Up @@ -619,7 +614,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, errors::Error, key::KeyBuilder};
/// # use meilisearch_sdk::{client::*, Error, KeyBuilder};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down Expand Up @@ -651,7 +646,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, errors::Error, key::KeyBuilder};
/// # use meilisearch_sdk::{client::*, Error, KeyBuilder};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down Expand Up @@ -686,7 +681,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, errors::Error, key::KeyBuilder, key::Action};
/// # use meilisearch_sdk::{client::*, Error, KeyBuilder, Action};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down Expand Up @@ -723,7 +718,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, errors::Error, key::KeyBuilder, key::KeyUpdater};
/// # use meilisearch_sdk::{client::*, Error, KeyBuilder, KeyUpdater};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down Expand Up @@ -794,7 +789,7 @@ impl Client {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, indexes::*, tasks::Task};
/// # use meilisearch_sdk::{client::*, indexes::*, Task};
/// # use serde::{Serialize, Deserialize};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
Expand Down Expand Up @@ -1105,11 +1100,7 @@ mod tests {

use meilisearch_test_macro::meilisearch_test;

use crate::{
client::*,
key::{Action, KeyBuilder},
tasks::TasksSearchQuery,
};
use crate::{client::*, Action, KeyBuilder, TasksSearchQuery};

#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Document {
Expand Down
22 changes: 9 additions & 13 deletions src/documents.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::task_info::TaskInfo;
use crate::TaskInfo;
use async_trait::async_trait;
use serde::{de::DeserializeOwned, Deserialize, Serialize};

Expand All @@ -20,10 +20,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
/// ## Sample usage:
/// ```
/// use serde::{Serialize, Deserialize};
/// use meilisearch_sdk::documents::IndexConfig;
/// use meilisearch_sdk::settings::Settings;
/// use meilisearch_sdk::indexes::Index;
/// use meilisearch_sdk::client::Client;
/// use meilisearch_sdk::{IndexConfig, Settings, Index, Client};
///
/// #[derive(Serialize, Deserialize, IndexConfig)]
/// struct Movie {
Expand All @@ -48,10 +45,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
/// ```
pub use meilisearch_index_setting_macro::IndexConfig;

use crate::settings::Settings;
use crate::tasks::Task;
use crate::Client;
use crate::{errors::Error, indexes::Index};
use crate::{Client, Error, Index, Settings, Task};

#[async_trait]
pub trait IndexConfig {
Expand Down Expand Up @@ -532,8 +526,8 @@ mod tests {

#[meilisearch_test]
async fn test_get_documents_with_error_hint() -> Result<(), Error> {
let url = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
let client = Client::new(format!("{}/hello", url), Some("masterKey"));
let meilisearch_url = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
let client = Client::new(format!("{}/hello", meilisearch_url), Some("masterKey"));
let index = client.index("test_get_documents_with_filter_wrong_ms_version");

let documents = DocumentsQuery::new(&index)
Expand All @@ -544,9 +538,11 @@ mod tests {
let error = documents.unwrap_err();

let message = Some("Hint: It might not be working because you're not up to date with the Meilisearch version that updated the get_documents_with method.".to_string());
let url = "http://localhost:7700/hello/indexes/test_get_documents_with_filter_wrong_ms_version/documents/fetch".to_string();
let url = format!(
"{meilisearch_url}/hello/indexes/test_get_documents_with_filter_wrong_ms_version/documents/fetch"
);
let status_code = 404;
let displayed_error = "MeilisearchCommunicationError: The server responded with a 404. Hint: It might not be working because you're not up to date with the Meilisearch version that updated the get_documents_with method.\nurl: http://localhost:7700/hello/indexes/test_get_documents_with_filter_wrong_ms_version/documents/fetch";
let displayed_error = format!("MeilisearchCommunicationError: The server responded with a 404. Hint: It might not be working because you're not up to date with the Meilisearch version that updated the get_documents_with method.\nurl: {meilisearch_url}/hello/indexes/test_get_documents_with_filter_wrong_ms_version/documents/fetch");

match &error {
Error::MeilisearchCommunication(error) => {
Expand Down
2 changes: 1 addition & 1 deletion src/dumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
//! # });
//! ```
use crate::{client::Client, errors::Error, request::*, task_info::TaskInfo};
use crate::{request::*, Client, Error, TaskInfo};

/// Dump related methods.
/// See the [dumps](crate::dumps) module.
Expand Down
12 changes: 4 additions & 8 deletions src/indexes.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use crate::{
client::Client,
documents::{DocumentDeletionQuery, DocumentQuery, DocumentsQuery, DocumentsResults},
errors::{Error, MeilisearchCommunicationError, MeilisearchError, MEILISEARCH_VERSION_HINT},
request::*,
search::*,
task_info::TaskInfo,
tasks::*,
request::*, search::*, tasks::*, Client, DocumentDeletionQuery, DocumentQuery, DocumentsQuery,
DocumentsResults, Error, MeilisearchCommunicationError, MeilisearchError, TaskInfo,
MEILISEARCH_VERSION_HINT,
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{collections::HashMap, fmt::Display, time::Duration};
Expand Down Expand Up @@ -114,7 +110,7 @@ impl Index {
/// # Example
///
/// ```
/// # use meilisearch_sdk::{client::*, indexes::*, task_info::*, tasks::{Task, SucceededTask}};
/// # use meilisearch_sdk::{client::*, indexes::*, task_info::*, Task, SucceededTask};
/// #
/// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
Expand Down
Loading

0 comments on commit 039ad9d

Please sign in to comment.