@@ -144,7 +144,7 @@ impl Display for DocType {
144144// document_type = [ 1* uuid_v4 ] 
145145// ; UUIDv4 
146146// uuid_v4 = #6.37(bytes .size 16) 
147- impl  Decode < ' _ ,  DecodeContext < ' _ > >  for  DocType  { 
147+ impl  Decode < ' _ ,  DecodeContext >  for  DocType  { 
148148 fn  decode ( 
149149 d :  & mut  Decoder ,  decode_context :  & mut  DecodeContext , 
150150 )  -> Result < Self ,  minicbor:: decode:: Error >  { 
@@ -155,15 +155,15 @@ impl Decode<'_, DecodeContext<'_>> for DocType {
155155 minicbor:: data:: Type :: Array  => { 
156156 let  len = d. array ( ) ?. ok_or_else ( || { 
157157 decode_context
158-  . report 
158+  . report ( ) 
159159 . other ( "Unable to decode array length" ,  CONTEXT ) ; 
160160 minicbor:: decode:: Error :: message ( format ! ( 
161161 "{CONTEXT}: Unable to decode array length" 
162162 ) ) 
163163 } ) ?; 
164164
165165 if  len == 0  { 
166-  decode_context. report . invalid_value ( 
166+  decode_context. report ( ) . invalid_value ( 
167167 "array length" , 
168168 "0" , 
169169 "must contain at least one UUIDv4" , 
@@ -180,7 +180,7 @@ impl Decode<'_, DecodeContext<'_>> for DocType {
180180 . map ( Self ) 
181181 . map_err ( |e| { 
182182 decode_context
183-  . report 
183+  . report ( ) 
184184 . other ( & format ! ( "Invalid UUIDv4 in array: {e}" ) ,  CONTEXT ) ; 
185185 minicbor:: decode:: Error :: message ( format ! ( 
186186 "{CONTEXT}: Invalid UUIDv4 in array: {e}" 
@@ -189,18 +189,15 @@ impl Decode<'_, DecodeContext<'_>> for DocType {
189189 } , 
190190 minicbor:: data:: Type :: Tag  => { 
191191 // Handle single tagged UUID 
192-  match  decode_context. compatibility_policy  { 
192+  match  decode_context. policy ( )  { 
193193 CompatibilityPolicy :: Accept  | CompatibilityPolicy :: Warn  => { 
194-  if  matches ! ( 
195-  decode_context. compatibility_policy, 
196-  CompatibilityPolicy :: Warn 
197-  )  { 
194+  if  matches ! ( decode_context. policy( ) ,  CompatibilityPolicy :: Warn )  { 
198195 warn ! ( "{CONTEXT}: Conversion of document type single UUID to type DocType" ) ; 
199196 } 
200197
201198 let  uuid = parse_uuid ( d) . map_err ( |e| { 
202199 let  msg = format ! ( "Cannot decode single UUIDv4: {e}" ) ; 
203-  decode_context. report . invalid_value ( 
200+  decode_context. report ( ) . invalid_value ( 
204201 "Decode single UUIDv4" , 
205202 & e. to_string ( ) , 
206203 & msg, 
@@ -214,15 +211,15 @@ impl Decode<'_, DecodeContext<'_>> for DocType {
214211
215212 CompatibilityPolicy :: Fail  => { 
216213 let  msg = "Conversion of document type single UUID to type DocType is not allowed" ; 
217-  decode_context. report . other ( msg,  CONTEXT ) ; 
214+  decode_context. report ( ) . other ( msg,  CONTEXT ) ; 
218215 Err ( minicbor:: decode:: Error :: message ( format ! ( 
219216 "{CONTEXT}: {msg}" 
220217 ) ) ) 
221218 } , 
222219 } 
223220 } , 
224221 other => { 
225-  decode_context. report . invalid_value ( 
222+  decode_context. report ( ) . invalid_value ( 
226223 "decoding type" , 
227224 & format ! ( "{other:?}" ) , 
228225 "array or tag cbor" , 
@@ -342,49 +339,45 @@ mod tests {
342339 fn  test_empty_doc_type_cbor_decode ( )  { 
343340 assert ! ( <DocType  as  TryFrom <Vec <UuidV4 >>>:: try_from( vec![ ] ) . is_err( ) ) ; 
344341
345-  let  mut  report = ProblemReport :: new ( "Test empty doc type" ) ; 
346-  let  mut  decoded_context = DecodeContext  { 
347-  compatibility_policy :  CompatibilityPolicy :: Accept , 
348-  report :  & mut  report, 
349-  } ; 
342+  let  mut  decoded_context = DecodeContext :: new ( 
343+  CompatibilityPolicy :: Accept , 
344+  ProblemReport :: new ( "Test empty doc type" ) , 
345+  ) ; 
350346 let  mut  decoder = Decoder :: new ( & [ ] ) ; 
351347 assert ! ( DocType :: decode( & mut  decoder,  & mut  decoded_context) . is_err( ) ) ; 
352348 } 
353349
354350 #[ test]  
355351 fn  test_single_uuid_doc_type_fail_policy_cbor_decode ( )  { 
356-  let  mut  report = ProblemReport :: new ( "Test single uuid doc type - fail" ) ; 
357352 let  data = hex:: decode ( PSA ) . unwrap ( ) ; 
358353 let  decoder = Decoder :: new ( & data) ; 
359-  let  mut  decoded_context = DecodeContext   { 
360-  compatibility_policy :   CompatibilityPolicy :: Fail , 
361-  report :   & mut  report , 
362-  } ; 
354+  let  mut  decoded_context = DecodeContext :: new ( 
355+  CompatibilityPolicy :: Fail , 
356+  ProblemReport :: new ( "Test single uuid doc type - fail" ) , 
357+  ) ; 
363358 assert ! ( DocType :: decode( & mut  decoder. clone( ) ,  & mut  decoded_context) . is_err( ) ) ; 
364359 } 
365360
366361 #[ test]  
367362 fn  test_single_uuid_doc_type_warn_policy_cbor_decode ( )  { 
368-  let  mut  report = ProblemReport :: new ( "Test single uuid doc type - warn" ) ; 
369363 let  data = hex:: decode ( PSA ) . unwrap ( ) ; 
370364 let  decoder = Decoder :: new ( & data) ; 
371-  let  mut  decoded_context = DecodeContext   { 
372-  compatibility_policy :   CompatibilityPolicy :: Warn , 
373-  report :   & mut  report , 
374-  } ; 
365+  let  mut  decoded_context = DecodeContext :: new ( 
366+  CompatibilityPolicy :: Warn , 
367+  ProblemReport :: new ( "Test single uuid doc type - warn" ) , 
368+  ) ; 
375369 let  decoded_doc_type = DocType :: decode ( & mut  decoder. clone ( ) ,  & mut  decoded_context) . unwrap ( ) ; 
376370 assert_eq ! ( decoded_doc_type. doc_types( ) . len( ) ,  3 ) ; 
377371 } 
378372
379373 #[ test]  
380374 fn  test_single_uuid_doc_type_accept_policy_cbor_decode ( )  { 
381-  let  mut  report = ProblemReport :: new ( "Test single uuid doc type - accept" ) ; 
382375 let  data = hex:: decode ( PSA ) . unwrap ( ) ; 
383376 let  decoder = Decoder :: new ( & data) ; 
384-  let  mut  decoded_context = DecodeContext   { 
385-  compatibility_policy :   CompatibilityPolicy :: Accept , 
386-  report :   & mut  report , 
387-  } ; 
377+  let  mut  decoded_context = DecodeContext :: new ( 
378+  CompatibilityPolicy :: Accept , 
379+  ProblemReport :: new ( "Test single uuid doc type - accept" ) , 
380+  ) ; 
388381 let  decoded_doc_type = DocType :: decode ( & mut  decoder. clone ( ) ,  & mut  decoded_context) . unwrap ( ) ; 
389382 assert_eq ! ( decoded_doc_type. doc_types( ) . len( ) ,  3 ) ; 
390383 } 
@@ -398,10 +391,7 @@ mod tests {
398391 let  mut  encoder = Encoder :: new ( & mut  buffer) ; 
399392 doc_type_list. encode ( & mut  encoder,  & mut  report) . unwrap ( ) ; 
400393 let  mut  decoder = Decoder :: new ( & buffer) ; 
401-  let  mut  decoded_context = DecodeContext  { 
402-  compatibility_policy :  CompatibilityPolicy :: Accept , 
403-  report :  & mut  report. clone ( ) , 
404-  } ; 
394+  let  mut  decoded_context = DecodeContext :: new ( CompatibilityPolicy :: Accept ,  report) ; 
405395 let  decoded_doc_type = DocType :: decode ( & mut  decoder,  & mut  decoded_context) . unwrap ( ) ; 
406396 assert_eq ! ( decoded_doc_type,  doc_type_list) ; 
407397 } 
0 commit comments