@@ -29,7 +29,7 @@ use role_index::RoleIndex;
2929/// Identifier (`URI`).
3030#[ derive( Debug , Clone ) ]
3131#[ allow( clippy:: module_name_repetitions) ]
32- pub struct KidURI {
32+ pub struct KidUri {
3333 /// Network
3434 network : String ,
3535 /// Sub Network
@@ -46,13 +46,13 @@ pub struct KidURI {
4646 encryption : bool ,
4747}
4848
49- impl KidURI {
49+ impl KidUri {
5050 /// Encryption Key Identifier Fragment
5151 const ENCRYPTION_FRAGMENT : & EStr < Fragment > = EStr :: new_or_panic ( "encrypt" ) ;
5252 /// URI scheme for Catalyst
5353 const SCHEME : & Scheme = Scheme :: new_or_panic ( "kid.catalyst-rbac" ) ;
5454
55- /// Get the network the `KidURI ` is referencing the registration to.
55+ /// Get the network the `KidUri ` is referencing the registration to.
5656 #[ must_use]
5757 pub fn network ( & self ) -> ( String , Option < String > ) {
5858 ( self . network . clone ( ) , self . subnet . clone ( ) )
@@ -83,8 +83,8 @@ impl KidURI {
8383 }
8484}
8585
86- impl KidURI {
87- /// Create a new `KidURI ` for a Signing Key
86+ impl KidUri {
87+ /// Create a new `KidUri ` for a Signing Key
8888 fn new (
8989 network : & str , subnet : Option < & str > , role0_pk : VerifyingKey , role : RoleIndex ,
9090 rotation : KeyRotation ,
@@ -99,7 +99,7 @@ impl KidURI {
9999 }
100100 }
101101
102- /// Create a new `KidURI ` for an Encryption Key
102+ /// Create a new `KidUri ` for an Encryption Key
103103 fn new_encryption (
104104 network : & str , subnet : Option < & str > , role0_pk : VerifyingKey , role : RoleIndex ,
105105 rotation : KeyRotation ,
@@ -110,21 +110,21 @@ impl KidURI {
110110 }
111111}
112112
113- impl FromStr for KidURI {
114- type Err = errors:: KidURIError ;
113+ impl FromStr for KidUri {
114+ type Err = errors:: KidUriError ;
115115
116116 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
117117 let uri = Uri :: parse ( s) ?;
118118
119119 // Check if its the correct scheme.
120- if uri. scheme ( ) != KidURI :: SCHEME {
121- return Err ( errors:: KidURIError :: InvalidScheme ) ;
120+ if uri. scheme ( ) != KidUri :: SCHEME {
121+ return Err ( errors:: KidUriError :: InvalidScheme ) ;
122122 }
123123
124124 // Decode the network and subnet
125125 let auth = uri
126126 . authority ( )
127- . ok_or ( errors:: KidURIError :: NoDefinedNetwork ) ?;
127+ . ok_or ( errors:: KidUriError :: NoDefinedNetwork ) ?;
128128 let network = auth. host ( ) ;
129129 let subnet = auth. userinfo ( ) . map ( std:: string:: ToString :: to_string) ;
130130
@@ -133,23 +133,23 @@ impl FromStr for KidURI {
133133 // Can ONLY have 3 path components, no more and no less
134134 // Less than 3 handled by errors below (4 because of leading `/` in path).
135135 if path. len ( ) > 4 {
136- return Err ( errors:: KidURIError :: InvalidPath ) ;
136+ return Err ( errors:: KidUriError :: InvalidPath ) ;
137137 } ;
138138
139139 // Decode and validate the Role0 Public key from the path
140- let encoded_role0_key = path. get ( 1 ) . ok_or ( errors:: KidURIError :: InvalidRole0Key ) ?;
140+ let encoded_role0_key = path. get ( 1 ) . ok_or ( errors:: KidUriError :: InvalidRole0Key ) ?;
141141 let decoded_role0_key =
142142 base64_url:: decode ( encoded_role0_key. decode ( ) . into_string_lossy ( ) . as_ref ( ) ) ?;
143143 let role0_pk = crate :: conversion:: vkey_from_bytes ( & decoded_role0_key)
144- . or ( Err ( errors:: KidURIError :: InvalidRole0Key ) ) ?;
144+ . or ( Err ( errors:: KidUriError :: InvalidRole0Key ) ) ?;
145145
146146 // Decode and validate the Role Index from the path.
147- let encoded_role_index = path. get ( 2 ) . ok_or ( errors:: KidURIError :: InvalidRole ) ?;
147+ let encoded_role_index = path. get ( 2 ) . ok_or ( errors:: KidUriError :: InvalidRole ) ?;
148148 let decoded_role_index = encoded_role_index. decode ( ) . into_string_lossy ( ) ;
149149 let role_index = decoded_role_index. parse :: < RoleIndex > ( ) ?;
150150
151151 // Decode and validate the Rotation Value from the path.
152- let encoded_rotation = path. get ( 3 ) . ok_or ( errors:: KidURIError :: InvalidRotation ) ?;
152+ let encoded_rotation = path. get ( 3 ) . ok_or ( errors:: KidUriError :: InvalidRotation ) ?;
153153 let decoded_rotation = encoded_rotation. decode ( ) . into_string_lossy ( ) ;
154154 let rotation = decoded_rotation. parse :: < KeyRotation > ( ) ?;
155155
@@ -158,7 +158,7 @@ impl FromStr for KidURI {
158158 if uri. fragment ( ) == Some ( Self :: ENCRYPTION_FRAGMENT ) {
159159 Self :: new_encryption ( network, subnet. as_deref ( ) , role0_pk, role_index, rotation)
160160 } else {
161- return Err ( errors:: KidURIError :: InvalidEncryptionKeyFragment ) ;
161+ return Err ( errors:: KidUriError :: InvalidEncryptionKeyFragment ) ;
162162 }
163163 } else {
164164 Self :: new ( network, subnet. as_deref ( ) , role0_pk, role_index, rotation)
@@ -169,7 +169,7 @@ impl FromStr for KidURI {
169169 }
170170}
171171
172- impl Display for KidURI {
172+ impl Display for KidUri {
173173 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
174174 write ! ( f, "{}://" , Self :: SCHEME . as_str( ) ) ?;
175175 if let Some ( subnet) = & self . subnet {
@@ -190,12 +190,12 @@ impl Display for KidURI {
190190 }
191191}
192192
193- impl TryFrom < & [ u8 ] > for KidURI {
194- type Error = errors:: KidURIError ;
193+ impl TryFrom < & [ u8 ] > for KidUri {
194+ type Error = errors:: KidUriError ;
195195
196196 fn try_from ( value : & [ u8 ] ) -> Result < Self , Self :: Error > {
197197 let kid_str = String :: from_utf8_lossy ( value) ;
198- KidURI :: from_str ( & kid_str)
198+ KidUri :: from_str ( & kid_str)
199199 }
200200}
201201
@@ -204,7 +204,7 @@ mod tests {
204204 use ed25519_dalek:: SigningKey ;
205205 use rand:: rngs:: OsRng ;
206206
207- use super :: KidURI ;
207+ use super :: KidUri ;
208208
209209 const KID_TEST_VECTOR : [ & str ; 5 ] = [
210210 "kid.catalyst-rbac://cardano/FftxFnOrj2qmTuB2oZG2v0YEWJfKvQ9Gg8AgNAhDsKE/0/0" ,
@@ -217,7 +217,7 @@ mod tests {
217217 #[ test]
218218 fn test_kid_uri_from_str ( ) {
219219 for kid_string in KID_TEST_VECTOR {
220- let kid = kid_string. parse :: < KidURI > ( ) . unwrap ( ) ;
220+ let kid = kid_string. parse :: < KidUri > ( ) . unwrap ( ) ;
221221 assert_eq ! ( format!( "{kid}" ) , kid_string) ;
222222 }
223223 }
0 commit comments