Struct meilisearch_sdk::client::Client[][src]

pub struct Client<'a> { /* fields omitted */ }

The top-level struct of the SDK, representing a client containing indexes.

Implementations

impl<'a> Client<'a>[src]

pub const fn new(host: &'a str, apikey: &'a str) -> Client<'a>[src]

Create a client using the specified server. Don’t put a ‘/’ at the end of the host. In production mode, see the documentation about authentication.

Example

// create the client
let client = Client::new("http://localhost:7700", "masterKey");

pub async fn list_all_indexes(&'a self) -> Result<Vec<Index<'a>>, Error>[src]

List all indexes.

Example

// create the client
let client = Client::new("http://localhost:7700", "masterKey");

let indexes: Vec<Index> = client.list_all_indexes().await.unwrap();
println!("{:?}", indexes);

pub async fn get_index(&'a self, uid: &'a str) -> Result<Index<'a>, Error>[src]

Get an index.

Example


// create the client
let client = Client::new("http://localhost:7700", "masterKey");

// get the index named "movies"
let movies = client.get_index("movies").await.unwrap();

pub fn assume_index(&'a self, uid: &'a str) -> Index<'a>[src]

Assume that an index exist and create a corresponding object without any check.

pub async fn create_index(
    &'a self,
    uid: &'a str,
    primary_key: Option<&str>
) -> Result<Index<'a>, Error>
[src]

Create an index. The second parameter will be used as the primary key of the new index. If it is not specified, MeiliSearch will try to infer the primary key.

Example

// create the client
let client = Client::new("http://localhost:7700", "masterKey");

// create a new index called movies and access it
let movies = client.create_index("movies", None).await;

pub async fn delete_index(&self, uid: &str) -> Result<(), Error>[src]

Delete an index from its UID. To delete an index from the index object, use the delete method.

pub async fn get_or_create(&'a self, uid: &'a str) -> Result<Index<'a>, Error>[src]

This will try to get an index and create the index if it does not exist.

pub async fn get_indexes(&'a self) -> Result<Vec<Index<'a>>, Error>[src]

Alias for list_all_indexes.

pub async fn get_stats(&self) -> Result<ClientStats, Error>[src]

Get stats of all indexes.

Example

let client = Client::new("http://localhost:7700", "masterKey");
let stats = client.get_stats().await.unwrap();

pub async fn health(&self) -> Result<(), Error>[src]

Get health of MeiliSearch server.

Example

let client = Client::new("http://localhost:7700", "masterKey");

match client.health().await {
    Ok(()) => println!("server is operational"),
    Err(Error::MeiliSearchError { error_code: ErrorCode::Maintenance, .. }) => {
        eprintln!("server is in maintenance")
    },
    Err(e) => panic!("should never happen: {}", e),
}

pub async fn get_keys(&self) -> Result<Keys, Error>[src]

Get the private and public key.

Example

let client = Client::new("http://localhost:7700", "masterKey");
let keys = client.get_keys().await.unwrap();

pub async fn get_version(&self) -> Result<Version, Error>[src]

Get version of the MeiliSearch server.

Example

let client = Client::new("http://localhost:7700", "masterKey");
let version = client.get_version().await.unwrap();

impl<'a> Client<'a>[src]

Dump related methods.
See the dumps module.

pub async fn create_dump(&self) -> Result<DumpInfo, Error>[src]

Triggers a dump creation process. Once the process is complete, a dump is created in the dumps directory. If the dumps directory does not exist yet, it will be created.

Example

let dump_info = client.create_dump().await.unwrap();
assert!(matches!(dump_info.status, DumpStatus::InProgress));

pub async fn get_dump_status(&self, dump_uid: &str) -> Result<DumpInfo, Error>[src]

Get the status of a dump creation process using the uid returned after calling the dump creation method.

Example

let dump_info = client.get_dump_status(&dump_info.uid).await.unwrap();

Trait Implementations

impl<'a> Debug for Client<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Client<'a>

impl<'a> Send for Client<'a>

impl<'a> Sync for Client<'a>

impl<'a> Unpin for Client<'a>

impl<'a> UnwindSafe for Client<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithSubscriber for T[src]