egg_mode/trend/mod.rs
1//! Sturcts and functions for working with trending topic in Twitter.
2//!
3//! In this module, you are able to get locations with trending topics.
4//!
5//! ## Types
6//! - `TrendLocation`: the element of trending information returned by trend API
7//! - `PlaceType`: a member in `TrendLocation`, which includes the code and related name
8//! to specify the kind of place
9use serde::{Deserialize, Serialize};
10
11mod fun;
12mod raw;
13
14pub use self::fun::*;
15
16round_trip! { raw::RawTrendLocation,
17 ///Reprsent the locations that Twitter has trending topic information
18 #[derive(Debug, Clone)]
19 pub struct TrendLocation {
20 ///The country of the location that Twitter has trending topic information for.
21 pub country: String,
22 ///short alphabetic or numeric geographical codes developed to represent countries
23 ///and dependent areas.
24 pub country_code: Option<String>,
25 ///The location with trending topic information.
26 pub name: String,
27 ///The woeid of the parent place.
28 pub parentid: u32,
29 ///The code and related name to specify the kind of location.
30 pub place_type: PlaceType,
31 ///The related url of woeid of the location. Note that the url returned in the response,
32 ///is no longer valid.
33 pub url: String,
34 ///The "where on earth identifier"
35 pub woeid: u32
36 }
37}
38
39impl From<raw::RawTrendLocation> for TrendLocation {
40 fn from(raw: raw::RawTrendLocation) -> TrendLocation {
41 TrendLocation {
42 country: raw.country,
43 country_code: raw.country_code,
44 name: raw.name,
45 parentid: raw.parentid,
46 place_type: raw.place_type,
47 url: raw.url,
48 woeid: raw.woeid,
49 }
50 }
51}
52
53///The code and related name to specify the kind of location.
54#[derive(Debug, Clone, Deserialize, Serialize)]
55pub struct PlaceType {
56 ///The code of the location type
57 pub code: u32,
58 ///The name of the location type
59 pub name: String,
60}