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: Clientcookie: Cookiecountry: Countrykeywords: Keywordslang: Langproperty: Propertytime: Stringcategory: Categoryresponse: Value

Implementations

Create a new Client.

Returns a Client.

Example

let keywords = Keywords::new(vec!["rust"]);
let country = Country::FR;

let client = Client::new(keywords, country);

Panics

Will panic if the client can’t be built. This can happen if the cookie can not be set or if the request time out.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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);

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.