pub struct RegionInterest {
    pub client: Client,
    pub resolution: &'static str,
}

Fields§

§client: Client§resolution: &'static str

Implementations§

source§

impl RegionInterest

source

pub fn new(client: Client) -> Self

Create a RegionInterest Instance.

Returns a RegionInterest instance

Examples found in repository?
examples/region_interest.rs (line 9)
3
4
5
6
7
8
9
10
11
fn main() {
    let country = Country::US;
    let keywords = Keywords::new(vec!["Instagram", "Facebook"]);
    
    let client = Client::new(keywords, country).build();
    
    let region_interest = RegionInterest::new(client).get();
    println!("{}", region_interest);
}
More examples
Hide additional examples
examples/select_keyword.rs (line 9)
3
4
5
6
7
8
9
10
11
fn main() {
    let country = Country::US;
    let keywords = Keywords::new(vec!["Instagram", "Facebook", "Pinterest"]);
    
    let client = Client::new(keywords, country).build();
    
    let region_interest_pinterest = RegionInterest::new(client).get_for("Pinterest");
    println!("{}", region_interest_pinterest);
}
examples/simple.rs (line 10)
3
4
5
6
7
8
9
10
11
12
fn main(){
    let country = Country::US;
    let keywords = Keywords::new(vec!["Instagram","Facebook"]);
    
    let client = Client::new(keywords, country).build();
    
    // Then select the data you want. The interest of your keywords filtered by region for example:
    let region_interest = RegionInterest::new(client).get();
    println!("{}", region_interest);
}
source

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

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?
examples/region_interest.rs (line 9)
3
4
5
6
7
8
9
10
11
fn main() {
    let country = Country::US;
    let keywords = Keywords::new(vec!["Instagram", "Facebook"]);
    
    let client = Client::new(keywords, country).build();
    
    let region_interest = RegionInterest::new(client).get();
    println!("{}", region_interest);
}
More examples
Hide additional examples
examples/simple.rs (line 10)
3
4
5
6
7
8
9
10
11
12
fn main(){
    let country = Country::US;
    let keywords = Keywords::new(vec!["Instagram","Facebook"]);
    
    let client = Client::new(keywords, country).build();
    
    // Then select the data you want. The interest of your keywords filtered by region for example:
    let region_interest = RegionInterest::new(client).get();
    println!("{}", region_interest);
}
source

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");
Examples found in repository?
examples/select_keyword.rs (line 9)
3
4
5
6
7
8
9
10
11
fn main() {
    let country = Country::US;
    let keywords = Keywords::new(vec!["Instagram", "Facebook", "Pinterest"]);
    
    let client = Client::new(keywords, country).build();
    
    let region_interest_pinterest = RegionInterest::new(client).get_for("Pinterest");
    println!("{}", region_interest_pinterest);
}

Trait Implementations§

source§

impl Clone for RegionInterest

source§

fn clone(&self) -> RegionInterest

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RegionInterest

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for RegionInterest

source§

fn default() -> Self

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

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more