Struct rtrend::client::Client [−][src]
pub struct Client { pub client: Client, pub cookie: Cookie, pub country: Country, pub keywords: Keywords, pub lang: Lang, pub property: Property, pub time: String, pub category: Category, pub response: Value, }
Fields
client: Client
country: Country
keywords: Keywords
lang: Lang
property: Property
time: String
category: Category
response: Value
Implementations
Set keywords and replace the ones setup during the client creation.
Returns a client instance.
Example
let keywords = Keywords::new(vec!["rust"]); let country = Country::FR; let client = Client::new(keywords, country); // ... let new_keywords = Keywords::new(vec!["python", "c++"]); let modified_client = client.with_keywords(new_keywords);
Set in which langage the response will be. The input need to be set in lowercase.
By default, the response is set to english (en).
Returns a client instance.
Example
let keywords = Keywords::new(vec!["rust"]); let country = Country::ALL; let lang = Lang::FR; // Set response langage to french let client = Client::new(keywords, country).with_lang(lang);
Set the category google trend will search on.
By default, any category is set.
Returns a client instance.
Example
let keywords = Keywords::new(vec!["hacking"]); let country = Country::ALL; let category = Category::EngineeringAndTechnology; // Set category to "Engineering & Technology" let client = Client::new(keywords, country).with_category(category);
Set the property google trend will search on.
By default, the search will be made on Google Search (web) The available property are :
web
,images
,news
,froogle
(Google Shopping),youtube
Returns a client instance.
Example
let keywords = Keywords::new(vec!["vlog"]); let country = Country::ALL; // The response will be retrieve from youtube data let property = Property::Youtube; let client = Client::new(keywords, country).with_property(property);
Set the period google trend will search on.
Period are preset set by Google Trend. By default, the search will be made on 1 year (starting by today).
Returns a client instance.
Example
let keywords = Keywords::new(vec!["vlog"]); let country = Country::ALL; // response will concern data from this week let client = Client::new(keywords, country).with_period(Period::SevenDay);
Set the “start date” and “end date” google trend will search on. By default, the search will be made on 1 year (starting by today).
Returns a client instance.
Example
let keywords = Keywords::new(vec!["vlog"]); let country = Country::ALL; // response will concern data from April 25, 2020 to July 30, 2021 let start_date: Date<Utc> = Utc.ymd(2017, 4, 25); let end_date: Date<Utc> = Utc.ymd(2020, 7, 30); let client = Client::new(keywords, country).with_date(start_date, end_date);
Allow to set options in one shot.
For now I don’t think it’s very useful but if it is, I will make it public
Returns a client instance.
Example
let keywords = Keywords::new(vec!["cat"]); let country = Country::ALL; let client = Client::new(keywords, country).with_filter( Category::PetsAndAnimals, Property::Images, // Search on Google Images "today 3-m".to_string(), // 90 previous days Lang::IT // in italian );
Build client and send request.
A response will be retrieve and available through the response
field.
This field will serve for making next requests.
Example
let keywords = Keywords::new(vec!["Cat"]); let country = Country::US; let client = Client::new(keywords, country).build(); println!("{}", client.response);
Trait Implementations
Default value for client
Returns a Default Client.
By default,
- The requested period is 1 year
- The Country is all the countries supported by google trend
- The Langage is English
- The Category is 0
- The response is empty (but valid json)
Example
let keywords = Keywords::new(vec!["rust"]); let country = Country::FR; let client = Client::new(keywords, country); println!("{:#?}", client);
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more