@@ -52,7 +52,7 @@ pub struct Settings {
5252 pub displayed_attributes : Option < Vec < String > > ,
5353}
5454
55- pub trait IntoVecString {
55+ pub trait IntoVecString : Sized {
5656 fn convert ( self ) -> Vec < String > ;
5757}
5858
@@ -410,17 +410,17 @@ impl<'a> Index<'a> {
410410 /// let client = Client::new("http://localhost:7700", "masterKey");
411411 /// let mut movie_index = client.get_or_create("movies").await.unwrap();
412412 ///
413- /// let stop_words = & ["the", "of", "to"];
414- /// let progress = movie_index.set_stop_words(stop_words).await.unwrap();
413+ /// let stop_words = ["the", "of", "to"];
414+ /// let progress = movie_index.set_stop_words(& stop_words[..] ).await.unwrap();
415415 /// # std::thread::sleep(std::time::Duration::from_secs(2));
416416 /// # progress.get_status().await.unwrap();
417417 /// # });
418418 /// ```
419- pub async fn set_stop_words ( & ' a self , stop_words : & [ & str ] ) -> Result < Progress < ' a > , Error > {
420- Ok ( request :: < & [ & str ] , ProgressJson > (
419+ pub async fn set_stop_words ( & ' a self , stop_words : impl IntoVecString ) -> Result < Progress < ' a > , Error > {
420+ Ok ( request :: < Vec < String > , ProgressJson > (
421421 & format ! ( "{}/indexes/{}/settings/stop-words" , self . client. host, self . uid) ,
422422 self . client . apikey ,
423- Method :: Post ( stop_words) ,
423+ Method :: Post ( stop_words. convert ( ) ) ,
424424 202 ,
425425 ) . await ?
426426 . into_progress ( self ) )
@@ -436,7 +436,7 @@ impl<'a> Index<'a> {
436436 /// let client = Client::new("http://localhost:7700", "masterKey");
437437 /// let mut movie_index = client.get_or_create("movies").await.unwrap();
438438 ///
439- /// let ranking_rules = & [
439+ /// let ranking_rules = [
440440 /// "typo",
441441 /// "words",
442442 /// "proximity",
@@ -446,16 +446,16 @@ impl<'a> Index<'a> {
446446 /// "asc(release_date)",
447447 /// "desc(rank)",
448448 /// ];
449- /// let progress = movie_index.set_ranking_rules(ranking_rules).await.unwrap();
449+ /// let progress = movie_index.set_ranking_rules(& ranking_rules[..] ).await.unwrap();
450450 /// # std::thread::sleep(std::time::Duration::from_secs(2));
451451 /// # progress.get_status().await.unwrap();
452452 /// # });
453453 /// ```
454- pub async fn set_ranking_rules ( & ' a self , ranking_rules : & [ & str ] ) -> Result < Progress < ' a > , Error > {
455- Ok ( request :: < & [ & str ] , ProgressJson > (
454+ pub async fn set_ranking_rules ( & ' a self , ranking_rules : impl IntoVecString ) -> Result < Progress < ' a > , Error > {
455+ Ok ( request :: < Vec < String > , ProgressJson > (
456456 & format ! ( "{}/indexes/{}/settings/ranking-rules" , self . client. host, self . uid) ,
457457 self . client . apikey ,
458- Method :: Post ( ranking_rules) ,
458+ Method :: Post ( ranking_rules. convert ( ) ) ,
459459 202 ,
460460 ) . await ?
461461 . into_progress ( self ) )
@@ -471,17 +471,17 @@ impl<'a> Index<'a> {
471471 /// let client = Client::new("http://localhost:7700", "masterKey");
472472 /// let mut movie_index = client.get_or_create("movies").await.unwrap();
473473 ///
474- /// let attributes_for_faceting = & ["genre", "director"];
475- /// let progress = movie_index.set_attributes_for_faceting(attributes_for_faceting).await.unwrap();
474+ /// let attributes_for_faceting = ["genre", "director"];
475+ /// let progress = movie_index.set_attributes_for_faceting(& attributes_for_faceting[..] ).await.unwrap();
476476 /// # std::thread::sleep(std::time::Duration::from_secs(2));
477477 /// # progress.get_status().await.unwrap();
478478 /// # });
479479 /// ```
480- pub async fn set_attributes_for_faceting ( & ' a self , attributes_for_faceting : & [ & str ] ) -> Result < Progress < ' a > , Error > {
481- Ok ( request :: < & [ & str ] , ProgressJson > (
480+ pub async fn set_attributes_for_faceting ( & ' a self , attributes_for_faceting : impl IntoVecString ) -> Result < Progress < ' a > , Error > {
481+ Ok ( request :: < Vec < String > , ProgressJson > (
482482 & format ! ( "{}/indexes/{}/settings/attributes-for-faceting" , self . client. host, self . uid) ,
483483 self . client . apikey ,
484- Method :: Post ( attributes_for_faceting) ,
484+ Method :: Post ( attributes_for_faceting. convert ( ) ) ,
485485 202 ,
486486 ) . await ?
487487 . into_progress ( self ) )
@@ -502,11 +502,11 @@ impl<'a> Index<'a> {
502502 /// # progress.get_status().await.unwrap();
503503 /// # });
504504 /// ```
505- pub async fn set_distinct_attribute ( & ' a self , distinct_attribute : & str ) -> Result < Progress < ' a > , Error > {
506- Ok ( request :: < & str , ProgressJson > (
505+ pub async fn set_distinct_attribute ( & ' a self , distinct_attribute : impl Into < String > ) -> Result < Progress < ' a > , Error > {
506+ Ok ( request :: < String , ProgressJson > (
507507 & format ! ( "{}/indexes/{}/settings/distinct-attribute" , self . client. host, self . uid) ,
508508 self . client . apikey ,
509- Method :: Post ( distinct_attribute) ,
509+ Method :: Post ( distinct_attribute. into ( ) ) ,
510510 202 ,
511511 ) . await ?
512512 . into_progress ( self ) )
@@ -522,16 +522,16 @@ impl<'a> Index<'a> {
522522 /// let client = Client::new("http://localhost:7700", "masterKey");
523523 /// let mut movie_index = client.get_or_create("movies").await.unwrap();
524524 ///
525- /// let progress = movie_index.set_searchable_attributes(&["title", "description", "uid"]).await.unwrap();
525+ /// let progress = movie_index.set_searchable_attributes(&["title", "description", "uid"][..] ).await.unwrap();
526526 /// # std::thread::sleep(std::time::Duration::from_secs(2));
527527 /// # progress.get_status().await.unwrap();
528528 /// # });
529529 /// ```
530- pub async fn set_searchable_attributes ( & ' a self , searchable_attributes : & [ & str ] ) -> Result < Progress < ' a > , Error > {
531- Ok ( request :: < & [ & str ] , ProgressJson > (
530+ pub async fn set_searchable_attributes ( & ' a self , searchable_attributes : impl IntoVecString ) -> Result < Progress < ' a > , Error > {
531+ Ok ( request :: < Vec < String > , ProgressJson > (
532532 & format ! ( "{}/indexes/{}/settings/searchable-attributes" , self . client. host, self . uid) ,
533533 self . client . apikey ,
534- Method :: Post ( searchable_attributes) ,
534+ Method :: Post ( searchable_attributes. convert ( ) ) ,
535535 202 ,
536536 ) . await ?
537537 . into_progress ( self ) )
@@ -547,16 +547,16 @@ impl<'a> Index<'a> {
547547 /// let client = Client::new("http://localhost:7700", "masterKey");
548548 /// let mut movie_index = client.get_or_create("movies").await.unwrap();
549549 ///
550- /// let progress = movie_index.set_displayed_attributes(&["title", "description", "release_date", "rank", "poster"]).await.unwrap();
550+ /// let progress = movie_index.set_displayed_attributes(&["title", "description", "release_date", "rank", "poster"][..] ).await.unwrap();
551551 /// # std::thread::sleep(std::time::Duration::from_secs(2));
552552 /// # progress.get_status().await.unwrap();
553553 /// # });
554554 /// ```
555- pub async fn set_displayed_attributes ( & ' a self , displayed_attributes : & [ & str ] ) -> Result < Progress < ' a > , Error > {
556- Ok ( request :: < & [ & str ] , ProgressJson > (
555+ pub async fn set_displayed_attributes ( & ' a self , displayed_attributes : impl IntoVecString ) -> Result < Progress < ' a > , Error > {
556+ Ok ( request :: < Vec < String > , ProgressJson > (
557557 & format ! ( "{}/indexes/{}/settings/displayed-attributes" , self . client. host, self . uid) ,
558558 self . client . apikey ,
559- Method :: Post ( displayed_attributes) ,
559+ Method :: Post ( displayed_attributes. convert ( ) ) ,
560560 202 ,
561561 ) . await ?
562562 . into_progress ( self ) )
0 commit comments