pub struct SearchQuery<'a> { /* private fields */ }
Expand description
A search query that can be used to search for documents on the web.
§Example
// You must have the SERPER_API_KEY environment variable set to run this example.
use kalosm_language::prelude::*;
#[tokio::main]
async fn main() {
let query = "What is the best way to learn a language?";
let api_key = std::env::var("SERPER_API_KEY").unwrap();
let search_query = SearchQuery::new(query, &api_key, 5);
let documents = search_query.into_documents().await.unwrap();
let mut text = String::new();
for document in documents {
for word in document.body().split(' ').take(300) {
text.push_str(word);
text.push(' ');
}
text.push('\n');
}
println!("{}", text);
}
Implementations§
Trait Implementations§
Source§impl IntoDocuments for SearchQuery<'_>
impl IntoDocuments for SearchQuery<'_>
Auto Trait Implementations§
impl<'a> Freeze for SearchQuery<'a>
impl<'a> RefUnwindSafe for SearchQuery<'a>
impl<'a> Send for SearchQuery<'a>
impl<'a> Sync for SearchQuery<'a>
impl<'a> Unpin for SearchQuery<'a>
impl<'a> UnwindSafe for SearchQuery<'a>
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> 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