pub struct DocumentQuery<'a, Http: HttpClient> {
pub index: &'a Index<Http>,
pub fields: Option<Vec<&'a str>>,
}
Fields§
§index: &'a Index<Http>
§fields: Option<Vec<&'a str>>
The fields that should appear in the documents. By default, all of the fields are present.
Implementations§
Source§impl<'a, Http: HttpClient> DocumentQuery<'a, Http>
impl<'a, Http: HttpClient> DocumentQuery<'a, Http>
pub fn new(index: &Index<Http>) -> DocumentQuery<'_, Http>
Sourcepub fn with_fields(
&mut self,
fields: impl IntoIterator<Item = &'a str>,
) -> &mut DocumentQuery<'a, Http>
pub fn with_fields( &mut self, fields: impl IntoIterator<Item = &'a str>, ) -> &mut DocumentQuery<'a, Http>
Specify the fields to return in the document.
§Example
let index = client.index("document_query_with_fields");
let mut document_query = DocumentQuery::new(&index);
document_query.with_fields(["title"]);
Sourcepub async fn execute<T: DeserializeOwned + 'static + Send + Sync>(
&self,
document_id: &str,
) -> Result<T, Error>
pub async fn execute<T: DeserializeOwned + 'static + Send + Sync>( &self, document_id: &str, ) -> Result<T, Error>
Execute the get document query.
§Example
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct MyObject {
id: String,
kind: String,
}
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct MyObjectReduced {
id: String,
}
let document = DocumentQuery::new(&index).with_fields(["id"])
.execute::<MyObjectReduced>("1")
.await
.unwrap();
assert_eq!(
document,
MyObjectReduced { id: "1".to_string() }
);
Trait Implementations§
Source§impl<'a, Http: Clone + HttpClient> Clone for DocumentQuery<'a, Http>
impl<'a, Http: Clone + HttpClient> Clone for DocumentQuery<'a, Http>
Source§fn clone(&self) -> DocumentQuery<'a, Http>
fn clone(&self) -> DocumentQuery<'a, Http>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a, Http: Debug + HttpClient> Debug for DocumentQuery<'a, Http>
impl<'a, Http: Debug + HttpClient> Debug for DocumentQuery<'a, Http>
Source§impl<'a, Http: HttpClient> Serialize for DocumentQuery<'a, Http>
impl<'a, Http: HttpClient> Serialize for DocumentQuery<'a, Http>
Auto Trait Implementations§
impl<'a, Http> Freeze for DocumentQuery<'a, Http>
impl<'a, Http> RefUnwindSafe for DocumentQuery<'a, Http>where
Http: RefUnwindSafe,
impl<'a, Http> Send for DocumentQuery<'a, Http>
impl<'a, Http> Sync for DocumentQuery<'a, Http>
impl<'a, Http> Unpin for DocumentQuery<'a, Http>
impl<'a, Http> UnwindSafe for DocumentQuery<'a, Http>where
Http: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more