33use serde:: {
44 Deserialize , Serialize ,
55 de:: { DeserializeSeed , Error } ,
6- ser:: Error as _,
76} ;
87use zvariant:: {
98 self , Array , DeserializeDict , DynamicDeserialize , LE , Optional , OwnedValue , SerializeDict ,
@@ -12,7 +11,7 @@ use zvariant::{
1211
1312use crate :: model:: { BackgroundEvent , Operation } ;
1413
15- const TAG_VALUE_SIGNATURE : & ' static Signature = & Signature :: Structure ( Fields :: Static {
14+ const TAG_VALUE_SIGNATURE : & Signature = & Signature :: Structure ( Fields :: Static {
1615 fields : & [ & Signature :: U8 , & Signature :: Variant ] ,
1716} ) ;
1817
@@ -266,11 +265,7 @@ impl Serialize for crate::model::HybridState {
266265 where
267266 S : serde:: Serializer ,
268267 {
269- let structure: Structure = self . try_into ( ) . map_err ( |err| {
270- S :: Error :: custom ( format ! (
271- "failed to read HybridState as D-Bus structure: {err}"
272- ) )
273- } ) ?;
268+ let structure: Structure = self . into ( ) ;
274269 structure. serialize ( serializer)
275270 }
276271}
@@ -295,7 +290,7 @@ impl TryFrom<&Structure<'_>> for crate::model::HybridState {
295290
296291 fn try_from ( structure : & Structure < ' _ > ) -> Result < Self , Self :: Error > {
297292 let ( tag, value) = parse_tag_value_struct ( structure) ?;
298- return match tag {
293+ match tag {
299294 0x01 => Ok ( Self :: Idle ) ,
300295 0x02 => {
301296 let qr_code: & str = value. downcast_ref ( ) ?;
@@ -309,7 +304,7 @@ impl TryFrom<&Structure<'_>> for crate::model::HybridState {
309304 _ => Err ( zvariant:: Error :: Message ( format ! (
310305 "Invalid HybridState type passed: {tag}"
311306 ) ) ) ,
312- } ;
307+ }
313308 }
314309}
315310
@@ -365,7 +360,7 @@ impl From<&crate::model::UsbState> for Structure<'_> {
365360 }
366361 crate :: model:: UsbState :: NeedsUserPresence => ( 0x07 , None ) ,
367362 crate :: model:: UsbState :: SelectCredential { creds } => {
368- let creds: Vec < Credential > = creds. into_iter ( ) . map ( Credential :: from) . collect ( ) ;
363+ let creds: Vec < Credential > = creds. iter ( ) . map ( Credential :: from) . collect ( ) ;
369364 let value = Value :: new ( creds) ;
370365 ( 0x08 , Some ( value) )
371366 }
@@ -506,7 +501,7 @@ fn parse_tag_value_struct<'a>(s: &'a Structure) -> Result<(u8, Value<'a>), zvari
506501 }
507502 let tag: u8 = s
508503 . fields ( )
509- . get ( 0 )
504+ . first ( )
510505 . ok_or_else ( || {
511506 zvariant:: Error :: SignatureMismatch (
512507 Signature :: U8 ,
0 commit comments