@@ -33,7 +33,9 @@ fn default_false() -> bool {
33
33
}
34
34
35
35
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize , Validate ) ]
36
+ #[ serde( rename_all = "camelCase" ) ]
36
37
pub struct Instance {
38
+ #[ serde( skip) ]
37
39
pub id : i32 ,
38
40
#[ serde( default = "String::new" ) ]
39
41
pub friendly_name : String ,
@@ -1136,6 +1138,7 @@ pub enum MetaError {
1136
1138
}
1137
1139
1138
1140
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
1141
+ #[ serde( rename_all = "camelCase" ) ]
1139
1142
pub struct Meta {
1140
1143
pub uuid : uuid:: Uuid ,
1141
1144
pub created_at : chrono:: DateTime < chrono:: Utc > ,
@@ -1168,6 +1171,7 @@ fn default_none<T>() -> Option<T> {
1168
1171
}
1169
1172
1170
1173
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
1174
+ #[ serde( rename_all = "camelCase" ) ]
1171
1175
pub struct User {
1172
1176
pub name : String ,
1173
1177
#[ serde(
@@ -1215,12 +1219,13 @@ impl TryFrom<db_models::DbUser> for User {
1215
1219
}
1216
1220
1217
1221
#[ derive( Default , Debug , Clone , PartialEq , Serialize , Deserialize , Validate ) ]
1218
- #[ serde( default ) ]
1222
+ #[ serde( default , rename_all = "camelCase" ) ]
1219
1223
pub struct GlobalConfig {
1220
1224
pub flatbuffers_server : FlatbuffersServer ,
1221
1225
pub forwarder : Forwarder ,
1222
1226
pub framegrabber : Framegrabber ,
1223
1227
pub general : General ,
1228
+ #[ serde( rename = "grabberV4L2" ) ]
1224
1229
pub grabber_v4l2 : GrabberV4L2 ,
1225
1230
pub json_server : JsonServer ,
1226
1231
pub logger : Logger ,
@@ -1261,6 +1266,7 @@ struct GlobalConfigCreator {
1261
1266
}
1262
1267
1263
1268
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize , Validate ) ]
1269
+ #[ serde( rename_all = "camelCase" ) ]
1264
1270
pub struct InstanceConfig {
1265
1271
#[ validate]
1266
1272
pub instance : Instance ,
@@ -1616,7 +1622,14 @@ impl Config {
1616
1622
let mut full = String :: new ( ) ;
1617
1623
file. read_to_string ( & mut full) . await ?;
1618
1624
1619
- Ok ( serde_json:: from_str ( & full) ?)
1625
+ let mut config: Self = serde_json:: from_str ( & full) ?;
1626
+
1627
+ // Restore instance IDs from map keys
1628
+ for ( & k, mut v) in config. instances . iter_mut ( ) {
1629
+ v. instance . id = k;
1630
+ }
1631
+
1632
+ Ok ( config)
1620
1633
}
1621
1634
1622
1635
pub fn uuid ( & self ) -> uuid:: Uuid {
0 commit comments