pub struct TrendsClient { /* private fields */ }Expand description
Google Trends client
Implementations§
Source§impl TrendsClient
impl TrendsClient
Sourcepub async fn new(
endpoint: String,
lang: Lang,
country: Country,
) -> Result<Self, Error>
pub async fn new( endpoint: String, lang: Lang, country: Country, ) -> Result<Self, Error>
Creates a new TrendsClient.
Sourcepub async fn try_default() -> Result<Self, Error>
pub async fn try_default() -> Result<Self, Error>
Returns a TrendsClient with default parameters.
Examples found in repository?
examples/simple_request.rs (line 19)
7async fn main() {
8 let simple_request = Request::new(
9 vec![ComparaisonElem {
10 keyword: "rust",
11 geo: Country::ALL,
12 time: Period::Predefined(PredefinedPeriod::OneYear),
13 }],
14 Category::RespiratoryConditions,
15 Property::Web,
16 )
17 .unwrap();
18
19 let client = TrendsClient::try_default().await.unwrap();
20 let explore_client = client.explore(simple_request).await.unwrap();
21
22 let stats = explore_client
23 .get_timeseries(&WidgetKeyword::All)
24 .await
25 .unwrap();
26
27 println!("{:?}", stats);
28}Sourcepub async fn explore<'a>(
self,
request: Request<'a>,
) -> Result<ExploreClient, Error>
pub async fn explore<'a>( self, request: Request<'a>, ) -> Result<ExploreClient, Error>
Returns an ExploreClient from a Request
The API is unstable when handling time ranges that combine very different scales. While long ranges (e.g. several months) are usually accepted, adding a small offset (e.g. a few hours) to the same range can cause the request to fail.
Examples found in repository?
examples/simple_request.rs (line 20)
7async fn main() {
8 let simple_request = Request::new(
9 vec![ComparaisonElem {
10 keyword: "rust",
11 geo: Country::ALL,
12 time: Period::Predefined(PredefinedPeriod::OneYear),
13 }],
14 Category::RespiratoryConditions,
15 Property::Web,
16 )
17 .unwrap();
18
19 let client = TrendsClient::try_default().await.unwrap();
20 let explore_client = client.explore(simple_request).await.unwrap();
21
22 let stats = explore_client
23 .get_timeseries(&WidgetKeyword::All)
24 .await
25 .unwrap();
26
27 println!("{:?}", stats);
28}Trait Implementations§
Source§impl Clone for TrendsClient
impl Clone for TrendsClient
Source§fn clone(&self) -> TrendsClient
fn clone(&self) -> TrendsClient
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 moreAuto Trait Implementations§
impl Freeze for TrendsClient
impl !RefUnwindSafe for TrendsClient
impl Send for TrendsClient
impl Sync for TrendsClient
impl Unpin for TrendsClient
impl !UnwindSafe for TrendsClient
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