profile_citm/
profile_citm.rs1use facet::Facet;
7use facet_json::from_str;
8use std::collections::HashMap;
9use std::hint::black_box;
10
11#[derive(Debug, Facet)]
12#[facet(rename_all = "camelCase")]
13struct CitmCatalog {
14 area_names: HashMap<String, String>,
15 audience_sub_category_names: HashMap<String, String>,
16 block_names: HashMap<String, String>,
17 events: HashMap<String, Event>,
18 performances: Vec<Performance>,
19 seat_category_names: HashMap<String, String>,
20 sub_topic_names: HashMap<String, String>,
21 subject_names: HashMap<String, String>,
22 topic_names: HashMap<String, String>,
23 topic_sub_topics: HashMap<String, Vec<u64>>,
24 venue_names: HashMap<String, String>,
25}
26
27#[derive(Debug, Facet)]
28#[facet(rename_all = "camelCase")]
29struct Event {
30 description: Option<String>,
31 id: u64,
32 logo: Option<String>,
33 name: String,
34 sub_topic_ids: Vec<u64>,
35 subject_code: Option<String>,
36 subtitle: Option<String>,
37 topic_ids: Vec<u64>,
38}
39
40#[derive(Debug, Facet)]
41#[facet(rename_all = "camelCase")]
42struct Performance {
43 event_id: u64,
44 id: u64,
45 logo: Option<String>,
46 name: Option<String>,
47 prices: Vec<Price>,
48 seat_categories: Vec<SeatCategory>,
49 seat_map_image: Option<String>,
50 start: u64,
51 venue_code: String,
52}
53
54#[derive(Debug, Facet)]
55#[facet(rename_all = "camelCase")]
56struct Price {
57 amount: u64,
58 audience_sub_category_id: u64,
59 seat_category_id: u64,
60}
61
62#[derive(Debug, Facet)]
63#[facet(rename_all = "camelCase")]
64struct SeatCategory {
65 areas: Vec<Area>,
66 seat_category_id: u64,
67}
68
69#[derive(Debug, Facet)]
70#[facet(rename_all = "camelCase")]
71struct Area {
72 area_id: u64,
73 block_ids: Vec<u64>,
74}
75
76fn main() {
77 let json = std::fs::read_to_string(concat!(
78 env!("CARGO_MANIFEST_DIR"),
79 "/../../citm_catalog.json"
80 ))
81 .expect("citm_catalog.json not found");
82
83 for _ in 0..100 {
84 let result: CitmCatalog = from_str(&json).unwrap();
85 black_box(result);
86 }
87}