11use crate :: { errors:: * , indexes:: * , request:: * , Rc } ;
2+ use serde:: Deserialize ;
23use serde_json:: { json, Value } ;
3- use serde:: { Deserialize } ;
44use std:: collections:: HashMap ;
55
66/// The top-level struct of the SDK, representing a client containing [indexes](../indexes/struct.Index.html).
@@ -25,7 +25,7 @@ impl Client {
2525 pub fn new ( host : impl Into < String > , api_key : impl Into < String > ) -> Client {
2626 Client {
2727 host : Rc :: new ( host. into ( ) ) ,
28- api_key : Rc :: new ( api_key. into ( ) )
28+ api_key : Rc :: new ( api_key. into ( ) ) ,
2929 }
3030 }
3131
@@ -44,8 +44,8 @@ impl Client {
4444 /// # });
4545 /// ```
4646 pub async fn list_all_indexes ( & self ) -> Result < Vec < Index > , Error > {
47- match self . list_all_indexes_raw ( ) . await {
48- Ok ( json_indexes) => Ok ( {
47+ match self . list_all_indexes_raw ( ) . await {
48+ Ok ( json_indexes) => Ok ( {
4949 let mut indexes = Vec :: new ( ) ;
5050 for json_index in json_indexes {
5151 indexes. push ( json_index. into_index ( self ) )
@@ -76,7 +76,8 @@ impl Client {
7676 & self . api_key ,
7777 Method :: Get ,
7878 200 ,
79- ) . await ?;
79+ )
80+ . await ?;
8081
8182 Ok ( json_indexes)
8283 }
@@ -99,7 +100,7 @@ impl Client {
99100 /// ```
100101 pub async fn get_index ( & self , uid : impl AsRef < str > ) -> Result < Index , Error > {
101102 match self . get_raw_index ( uid) . await {
102- Ok ( raw_idx) => Ok ( raw_idx. into_index ( self ) ) ,
103+ Ok ( raw_idx) => Ok ( raw_idx. into_index ( self ) ) ,
103104 Err ( error) => Err ( error) ,
104105 }
105106 }
@@ -130,7 +131,7 @@ impl Client {
130131 Index {
131132 uid : Rc :: new ( uid. into ( ) ) ,
132133 host : Rc :: clone ( & self . host ) ,
133- api_key : Rc :: clone ( & self . api_key )
134+ api_key : Rc :: clone ( & self . api_key ) ,
134135 }
135136 }
136137
@@ -165,16 +166,17 @@ impl Client {
165166 "primaryKey" : primary_key,
166167 } ) ) ,
167168 201 ,
168- ) . await ?
169+ )
170+ . await ?
169171 . into_index ( self ) )
170172 }
171173
172174 /// Delete an index from its UID if it exists.
173175 /// To delete an index if it exists from the [`Index`] object, use the [Index::delete_if_exists] method.
174176 pub async fn delete_index_if_exists ( & self , uid : & str ) -> Result < bool , Error > {
175177 match self . delete_index ( uid) . await {
176- Ok ( _) => Ok ( true ) ,
177- Err ( Error :: MeiliSearchError {
178+ Ok ( _) => Ok ( true ) ,
179+ Err ( Error :: MeiliSearchError {
178180 error_message : _,
179181 error_code : ErrorCode :: IndexNotFound ,
180182 error_type : _,
@@ -192,7 +194,8 @@ impl Client {
192194 & self . api_key ,
193195 Method :: Delete ,
194196 204 ,
195- ) . await ?)
197+ )
198+ . await ?)
196199 }
197200
198201 /// This will try to get an index and create the index if it does not exist.
@@ -232,7 +235,8 @@ impl Client {
232235 & self . api_key ,
233236 Method :: Get ,
234237 200 ,
235- ) . await
238+ )
239+ . await
236240 }
237241
238242 /// Get health of MeiliSearch server.
@@ -296,7 +300,8 @@ impl Client {
296300 & self . api_key ,
297301 Method :: Get ,
298302 200 ,
299- ) . await
303+ )
304+ . await
300305 }
301306
302307 /// Get version of the MeiliSearch server.
@@ -317,7 +322,8 @@ impl Client {
317322 & self . api_key ,
318323 Method :: Get ,
319324 200 ,
320- ) . await
325+ )
326+ . await
321327 }
322328}
323329
@@ -373,7 +379,7 @@ pub struct Version {
373379
374380#[ cfg( test) ]
375381mod tests {
376- use crate :: { client:: * } ;
382+ use crate :: client:: * ;
377383 use futures_await_test:: async_test;
378384
379385 #[ async_test]
@@ -462,7 +468,10 @@ mod tests {
462468 async fn test_get_primary_key ( ) {
463469 let client = Client :: new ( "http://localhost:7700" , "masterKey" ) ;
464470 let index_name = "get_primary_key" ;
465- client. create_index ( index_name, Some ( "primary_key" ) ) . await . unwrap ( ) ;
471+ client
472+ . create_index ( index_name, Some ( "primary_key" ) )
473+ . await
474+ . unwrap ( ) ;
466475 let primary_key = client. index ( index_name) . get_primary_key ( ) . await ;
467476 assert ! ( primary_key. is_ok( ) ) ;
468477 assert_eq ! ( primary_key. unwrap( ) . unwrap( ) , "primary_key" ) ;
0 commit comments