Struct rtrend::region_interest::RegionInterest
source · pub struct RegionInterest {
pub client: Client,
pub resolution: &'static str,
}
Fields§
§client: Client
§resolution: &'static str
Implementations§
source§impl RegionInterest
impl RegionInterest
sourcepub fn new(client: Client) -> Self
pub fn new(client: Client) -> Self
Create a RegionInterest
Instance.
Returns a RegionInterest
instance
Examples found in repository?
More examples
sourcepub fn with_filter(self, scale: &'static str) -> Self
pub fn with_filter(self, scale: &'static str) -> Self
Add a geographic filter. You can filter result by “REGION” and “CITY”.
Warning : When making a request on all countries, use “COUNTRY” instead of “REGION” else it will panic
Returns a RegionInterest
instance.
Example
let keywords = Keywords::new(vec!["hacker"]);
let country = Country::US;
let client = Client::new(keywords, country).build();
let region_interest = RegionInterest::new(client).with_filter("CITY").get();
println!("{}", region_interest);
Panics
By default, on google trend, when making request on all countries, the country are called region (when you use filter). But we can’t use the keyword REGION to filter by COUNTRY. So instead use the keyword “COUNTRY”
This example will panic
let keywords = Keywords::new(vec!["hacker"]);
let country = Country::ALL;
let client = Client::new(keywords, country).build();
let region_interest = RegionInterest::new(client).with_filter("REGION").get();
println!("{}", region_interest);
Instead do not filter and let the default value or use the “COUNTRY” filter
let keywords = Keywords::new(vec!["hacker"]);
let country = Country::ALL;
let client = Client::new(keywords, country).build();
let region_interest = RegionInterest::new(client).with_filter("COUNTRY").get();
// or
// let region_interest = RegionInterest::new(client).get();
// will return the same result
println!("{}", region_interest);
sourcepub fn get(&self) -> Value
pub fn get(&self) -> Value
Retrieve maps data for all keywords.
Retrieve data for all keywords set within the client.
Returns a JSON serde Value (serde_json::Value
).
Example
let keywords = Keywords::new(vec!["hacker"]);
let country = Country::US;
let client = Client::new(keywords, country).build();
let region_interest = RegionInterest::new(client).get();
println!("{}", region_interest);
Panics
Panic if the client have not been built.
let keywords = Keywords::new(vec!["hacker"]);
let country = Country::US;
// Client not built
let client = Client::new(keywords, country);
let region_interest = RegionInterest::new(client).get();
Examples found in repository?
More examples
sourcepub fn get_for(&self, keyword: &str) -> Value
pub fn get_for(&self, keyword: &str) -> Value
Retrieve maps data for a specific keywords.
Retrieve the data for one keywords set within the client.
Returns a JSON serde Value (serde_json::Value
).
Example
let keywords = Keywords::new(vec!["PS4","XBOX","PC"]);
let country = Country::ALL;
let client = Client::new(keywords, country).build();
let region_interest = RegionInterest::new(client).get_for("PS4");
println!("{}", region_interest);
Panics
Will panic if input keyword have not been set previously for the client.
let keywords = Keywords::new(vec!["PS4","XBOX","PC"]);
let country = Country::ALL;
let client = Client::new(keywords, country).build();
let region_interest = RegionInterest::new(client).get_for("WII");
Trait Implementations§
source§impl Clone for RegionInterest
impl Clone for RegionInterest
source§fn clone(&self) -> RegionInterest
fn clone(&self) -> RegionInterest
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more