@@ -795,20 +795,20 @@ mod test {
795795 fn credential_data ( ) -> CredentialData {
796796 CredentialData {
797797 rp : Rp :: new ( PublicKeyCredentialRpEntity {
798- id : String :: from ( "John Doe" ) ,
798+ id : String :: try_from ( "John Doe" ) . unwrap ( ) ,
799799 name : None ,
800800 icon : None ,
801801 } ) ,
802802 user : User :: new ( PublicKeyCredentialUserEntity {
803- id : Bytes :: from_slice ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ,
803+ id : Bytes :: try_from ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ,
804804 icon : None ,
805805 name : None ,
806806 display_name : None ,
807807 } ) ,
808808 creation_time : 123 ,
809809 use_counter : false ,
810810 algorithm : -7 ,
811- key : Key :: WrappedKey ( Bytes :: from_slice ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ) ,
811+ key : Key :: WrappedKey ( Bytes :: try_from ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ) ,
812812 hmac_secret : Some ( false ) ,
813813 cred_protect : None ,
814814 use_short_id : Some ( true ) ,
@@ -822,15 +822,15 @@ mod test {
822822 rp : Rp {
823823 format : SerializationFormat :: Long ,
824824 inner : PublicKeyCredentialRpEntity {
825- id : String :: from ( "John Doe" ) ,
825+ id : String :: try_from ( "John Doe" ) . unwrap ( ) ,
826826 name : None ,
827827 icon : None ,
828828 } ,
829829 } ,
830830 user : User {
831831 format : SerializationFormat :: Long ,
832832 inner : PublicKeyCredentialUserEntity {
833- id : Bytes :: from_slice ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ,
833+ id : Bytes :: try_from ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ,
834834 icon : None ,
835835 name : None ,
836836 display_name : None ,
@@ -839,7 +839,7 @@ mod test {
839839 creation_time : 123 ,
840840 use_counter : false ,
841841 algorithm : -7 ,
842- key : Key :: WrappedKey ( Bytes :: from_slice ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ) ,
842+ key : Key :: WrappedKey ( Bytes :: try_from ( & [ 1 , 2 , 3 ] ) . unwrap ( ) ) ,
843843 hmac_secret : Some ( false ) ,
844844 cred_protect : None ,
845845 use_short_id : None ,
@@ -866,7 +866,7 @@ mod test {
866866 let between = Uniform :: from ( 0 ..( N + 1 ) ) ;
867867 let n = between. sample ( & mut OsRng ) ;
868868
869- bytes. resize_default ( n) . unwrap ( ) ;
869+ bytes. resize_zero ( n) . unwrap ( ) ;
870870
871871 OsRng . fill_bytes ( & mut bytes) ;
872872 bytes
@@ -1080,7 +1080,7 @@ mod test {
10801080 #[ test]
10811081 fn max_credential_id ( ) {
10821082 let rp_id: String < 256 > = core:: iter:: repeat_n ( '?' , 256 ) . collect ( ) ;
1083- let key = Bytes :: from_slice ( & [ u8:: MAX ; 128 ] ) . unwrap ( ) ;
1083+ let key = Bytes :: try_from ( & [ u8:: MAX ; 128 ] ) . unwrap ( ) ;
10841084 let credential = StrippedCredential {
10851085 ctap : CtapVersion :: Fido21Pre ,
10861086 creation_time : u32:: MAX ,
@@ -1161,8 +1161,8 @@ mod test {
11611161
11621162 fn inner ( & self ) -> PublicKeyCredentialRpEntity {
11631163 PublicKeyCredentialRpEntity {
1164- id : self . id . into ( ) ,
1165- name : self . name . map ( From :: from ) ,
1164+ id : self . id . try_into ( ) . unwrap ( ) ,
1165+ name : self . name . map ( |n| n . try_into ( ) . unwrap ( ) ) ,
11661166 icon : None ,
11671167 }
11681168 }
@@ -1226,10 +1226,10 @@ mod test {
12261226
12271227 fn inner ( & self ) -> PublicKeyCredentialUserEntity {
12281228 PublicKeyCredentialUserEntity {
1229- id : Bytes :: from_slice ( self . id ) . unwrap ( ) ,
1230- icon : self . icon . map ( From :: from ) ,
1231- name : self . name . map ( From :: from ) ,
1232- display_name : self . display_name . map ( From :: from ) ,
1229+ id : Bytes :: try_from ( self . id ) . unwrap ( ) ,
1230+ icon : self . icon . map ( |v| v . try_into ( ) . unwrap ( ) ) ,
1231+ name : self . name . map ( |v| v . try_into ( ) . unwrap ( ) ) ,
1232+ display_name : self . display_name . map ( |v| v . try_into ( ) . unwrap ( ) ) ,
12331233 }
12341234 }
12351235 }
@@ -1301,7 +1301,7 @@ mod test {
13011301 "
13021302 ) ;
13031303
1304- let credential = FullCredential :: deserialize ( & Bytes :: from_slice ( & data) . unwrap ( ) ) . unwrap ( ) ;
1304+ let credential = FullCredential :: deserialize ( & Bytes :: try_from ( & data) . unwrap ( ) ) . unwrap ( ) ;
13051305 assert ! ( matches!( credential. ctap, CtapVersion :: Fido21Pre ) ) ;
13061306 assert_eq ! ( credential. nonce, & hex!( "F62CA01ED181A3D03D561FC7" ) ) ;
13071307 assert_eq ! (
@@ -1310,17 +1310,17 @@ mod test {
13101310 rp: Rp {
13111311 format: SerializationFormat :: Long ,
13121312 inner: PublicKeyCredentialRpEntity {
1313- id: "webauthn.io" . into ( ) ,
1313+ id: "webauthn.io" . try_into ( ) . unwrap ( ) ,
13141314 name: None ,
13151315 icon: None ,
13161316 } ,
13171317 } ,
13181318 user: User {
13191319 format: SerializationFormat :: Long ,
13201320 inner: PublicKeyCredentialUserEntity {
1321- id: Bytes :: from_slice ( & hex!( "6447567A644445" ) ) . unwrap( ) ,
1321+ id: Bytes :: try_from ( & hex!( "6447567A644445" ) ) . unwrap( ) ,
13221322 icon: None ,
1323- name: Some ( "test1" . into ( ) ) ,
1323+ name: Some ( "test1" . try_into ( ) . unwrap ( ) ) ,
13241324 display_name: None ,
13251325 } ,
13261326 } ,
0 commit comments