@@ -57,8 +57,8 @@ use std::fmt::Debug;
57
57
use serde:: { Deserialize , Serialize } ;
58
58
use serde_json:: { from_value, json, Value } ;
59
59
60
- use crate :: error:: { ApiError , ApiResult } ;
61
- use crate :: hue :: legacy_api:: ApiLightStateUpdate ;
60
+ use crate :: error:: { HueError , HueResult } ;
61
+ use crate :: legacy_api:: ApiLightStateUpdate ;
62
62
63
63
#[ derive( Debug , Deserialize , Clone , Default ) ]
64
64
#[ serde( deny_unknown_fields) ]
@@ -189,7 +189,7 @@ impl Resource {
189
189
}
190
190
}
191
191
192
- pub fn from_value ( rtype : RType , obj : Value ) -> ApiResult < Self > {
192
+ pub fn from_value ( rtype : RType , obj : Value ) -> HueResult < Self > {
193
193
let res = match rtype {
194
194
RType :: AuthV1 => Self :: AuthV1 ( from_value ( obj) ?) ,
195
195
RType :: BehaviorInstance => Self :: BehaviorInstance ( from_value ( obj) ?) ,
@@ -232,37 +232,37 @@ impl Resource {
232
232
macro_rules! resource_conversion_impl {
233
233
( $name: ident ) => {
234
234
impl <' a> TryFrom <& ' a mut Resource > for & ' a mut $name {
235
- type Error = ApiError ;
235
+ type Error = HueError ;
236
236
237
237
fn try_from( value: & ' a mut Resource ) -> Result <Self , Self :: Error > {
238
238
if let Resource :: $name( obj) = value {
239
239
Ok ( obj)
240
240
} else {
241
- Err ( ApiError :: WrongType ( RType :: Light , value. rtype( ) ) )
241
+ Err ( HueError :: WrongType ( RType :: Light , value. rtype( ) ) )
242
242
}
243
243
}
244
244
}
245
245
246
246
impl <' a> TryFrom <& ' a Resource > for & ' a $name {
247
- type Error = ApiError ;
247
+ type Error = HueError ;
248
248
249
249
fn try_from( value: & ' a Resource ) -> Result <Self , Self :: Error > {
250
250
if let Resource :: $name( obj) = value {
251
251
Ok ( obj)
252
252
} else {
253
- Err ( ApiError :: WrongType ( RType :: Light , value. rtype( ) ) )
253
+ Err ( HueError :: WrongType ( RType :: Light , value. rtype( ) ) )
254
254
}
255
255
}
256
256
}
257
257
258
258
impl TryFrom <Resource > for $name {
259
- type Error = ApiError ;
259
+ type Error = HueError ;
260
260
261
261
fn try_from( value: Resource ) -> Result <Self , Self :: Error > {
262
262
if let Resource :: $name( obj) = value {
263
263
Ok ( obj)
264
264
} else {
265
- Err ( ApiError :: WrongType ( RType :: Light , value. rtype( ) ) )
265
+ Err ( HueError :: WrongType ( RType :: Light , value. rtype( ) ) )
266
266
}
267
267
}
268
268
}
@@ -303,12 +303,6 @@ resource_conversion_impl!(ZigbeeConnectivity);
303
303
resource_conversion_impl ! ( ZigbeeDeviceDiscovery ) ;
304
304
resource_conversion_impl ! ( Zone ) ;
305
305
306
- #[ derive( Debug , Serialize , Deserialize ) ]
307
- pub struct V2Reply < T > {
308
- pub data : Vec < T > ,
309
- pub errors : Vec < String > ,
310
- }
311
-
312
306
#[ derive( Clone , Debug , Serialize ) ]
313
307
pub struct V1Reply < ' a > {
314
308
prefix : String ,
@@ -339,19 +333,19 @@ impl<'a> V1Reply<'a> {
339
333
Self :: new ( format ! ( "/groups/{id}" ) )
340
334
}
341
335
342
- pub fn with_light_state_update ( self , upd : & ApiLightStateUpdate ) -> ApiResult < Self > {
336
+ pub fn with_light_state_update ( self , upd : & ApiLightStateUpdate ) -> HueResult < Self > {
343
337
self . add_option ( "on" , upd. on ) ?
344
338
. add_option ( "bri" , upd. bri ) ?
345
339
. add_option ( "xy" , upd. xy ) ?
346
340
. add_option ( "ct" , upd. ct )
347
341
}
348
342
349
- pub fn add < T : Serialize > ( mut self , name : & ' a str , value : T ) -> ApiResult < Self > {
343
+ pub fn add < T : Serialize > ( mut self , name : & ' a str , value : T ) -> HueResult < Self > {
350
344
self . success . push ( ( name, serde_json:: to_value ( value) ?) ) ;
351
345
Ok ( self )
352
346
}
353
347
354
- pub fn add_option < T : Serialize > ( mut self , name : & ' a str , value : Option < T > ) -> ApiResult < Self > {
348
+ pub fn add_option < T : Serialize > ( mut self , name : & ' a str , value : Option < T > ) -> HueResult < Self > {
355
349
if let Some ( val) = value {
356
350
self . success . push ( ( name, serde_json:: to_value ( val) ?) ) ;
357
351
}
0 commit comments