@@ -120,15 +120,28 @@ pub struct DeviceConfiguration {
120120 pub device : Device ,
121121}
122122
123- #[ derive( Default , Serialize , Deserialize ) ]
123+ #[ derive( Serialize , Deserialize ) ]
124124#[ serde( default ) ]
125125pub struct Device {
126+ pub id : Uuid ,
126127 pub name : String ,
127128 pub description : String ,
128129 pub firmware : Vec < DeviceFirmware > ,
129130 pub metadata : DeviceMetadata ,
130131}
131132
133+ impl Default for Device {
134+ fn default ( ) -> Self {
135+ Device {
136+ id : Uuid :: new_v4 ( ) ,
137+ name : "" . into ( ) ,
138+ description : "" . into ( ) ,
139+ firmware : vec ! [ ] ,
140+ metadata : DeviceMetadata :: default ( ) ,
141+ }
142+ }
143+ }
144+
132145#[ derive( Default , Serialize , Deserialize ) ]
133146pub struct DeviceMetadata {
134147 pub product_url : Option < String > ,
@@ -260,6 +273,7 @@ impl From<&api::Device> for DeviceConfiguration {
260273 fn from ( value : & api:: Device ) -> Self {
261274 DeviceConfiguration {
262275 device : Device {
276+ id : Uuid :: from_str ( & value. id ) . unwrap_or_else ( |_| Uuid :: new_v4 ( ) ) ,
263277 name : value. name . clone ( ) ,
264278 description : value. description . clone ( ) ,
265279 metadata : value
@@ -304,6 +318,7 @@ impl From<&DeviceConfiguration> for api::Device {
304318 vendor_dir : "" . into ( ) ,
305319 file : "" . into ( ) ,
306320
321+ id : value. id . to_string ( ) ,
307322 name : value. name . clone ( ) ,
308323 description : value. description . clone ( ) ,
309324 firmware : value
0 commit comments