-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathlight_rolling_stock.rs
94 lines (86 loc) · 3.04 KB
/
light_rolling_stock.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use diesel::sql_types::{Array, BigInt, Bool, Double, Jsonb, Nullable, Text};
use diesel_json::Json as DieselJson;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use utoipa::ToSchema;
use crate::models::rolling_stock::rolling_stock_livery::RollingStockLiveryMetadata;
use super::{EnergySource, Gamma, RollingResistance, RollingStockMetadata};
crate::schemas! {
LightRollingStock,
LightRollingStockWithLiveries,
LightModeEffortCurves,
LightEffortCurves,
}
#[derive(Debug, QueryableByName, Deserialize, Serialize, ToSchema)]
pub struct LightRollingStock {
#[diesel(sql_type = BigInt)]
pub id: i64,
#[diesel(sql_type = Text)]
pub name: String,
#[diesel(sql_type = Text)]
pub railjson_version: String,
#[diesel(sql_type = Bool)]
pub locked: bool,
#[diesel(sql_type = Jsonb)]
#[schema(value_type = LightEffortCurves)]
pub effort_curves: DieselJson<LightEffortCurves>,
#[diesel(sql_type = Nullable<Text>)]
pub base_power_class: Option<String>,
#[diesel(sql_type = Double)]
pub length: f64,
#[diesel(sql_type = Double)]
pub max_speed: f64,
#[diesel(sql_type = Double)]
pub startup_time: f64,
#[diesel(sql_type = Double)]
pub startup_acceleration: f64,
#[diesel(sql_type = Double)]
pub comfort_acceleration: f64,
#[diesel(sql_type = Jsonb)]
#[schema(value_type = Gamma)]
pub gamma: DieselJson<Gamma>,
#[diesel(sql_type = Double)]
pub inertia_coefficient: f64,
#[diesel(sql_type = Double)]
pub mass: f64,
#[diesel(sql_type = Jsonb)]
#[schema(value_type = RollingResistance)]
pub rolling_resistance: DieselJson<RollingResistance>,
#[diesel(sql_type = Text)]
#[schema(value_type = LoadingGaugeType)]
pub loading_gauge: String,
#[diesel(sql_type = Jsonb)]
#[schema(value_type = RollingStockMetadata)]
pub metadata: DieselJson<RollingStockMetadata>,
#[diesel(sql_type = Nullable<Jsonb>)]
#[schema(value_type = HashMap<String, String>)]
pub power_restrictions: Option<DieselJson<HashMap<String, String>>>,
#[diesel(sql_type = Jsonb)]
#[schema(value_type = Vec<EnergySource>)]
pub energy_sources: DieselJson<Vec<EnergySource>>,
#[serde(skip)]
#[diesel(sql_type = BigInt)]
pub version: i64,
#[diesel(sql_type = Array<Text>)]
pub supported_signaling_systems: Vec<String>,
}
#[derive(Debug, QueryableByName, Serialize, Deserialize, ToSchema)]
pub struct LightRollingStockWithLiveries {
#[diesel(embed)]
#[serde(flatten)]
pub rolling_stock: LightRollingStock,
#[diesel(sql_type = Array<Jsonb>)]
#[schema(value_type = Vec<RollingStockLiveryMetadata>)]
pub liveries: Vec<DieselJson<RollingStockLiveryMetadata>>,
}
// Light effort curves schema for LightRollingStock
#[derive(Debug, Deserialize, Serialize, ToSchema)]
pub struct LightModeEffortCurves {
is_electric: bool,
}
#[derive(Debug, Deserialize, Serialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct LightEffortCurves {
modes: HashMap<String, LightModeEffortCurves>,
default_mode: String,
}