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

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.
If you are not in production mode, the second field is useless. In production mode, see the documentation to get the needed key.

Example

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

pub 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", "");

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

pub 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", "");

// get the index named "movies"
let movies = client.get_index("movies").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 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", "");

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

pub 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 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 fn get_indexes(&'a self) -> Result<Vec<Index<'a>>, Error>[src]

Alias for list_all_indexes.

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, 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.