11use std:: { fmt:: Debug , fs:: OpenOptions , io:: Write , path:: Path , slice} ;
22
33use crate :: {
4- codes_message:: CodesMessage ,
4+ codes_message:: { BufMessage , CodesMessage } ,
55 errors:: CodesError ,
66 intermediate_bindings:: {
77 codes_get_message, codes_set_bytes, codes_set_double, codes_set_double_array,
@@ -46,7 +46,7 @@ pub trait KeyWrite<T> {
4646
4747macro_rules! impl_key_write {
4848 ( $ec_func: ident, $gen_type: ty) => {
49- impl < P : Debug > KeyWrite <$gen_type> for CodesMessage < P > {
49+ impl KeyWrite <$gen_type> for BufMessage {
5050 fn write_key_unchecked(
5151 & mut self ,
5252 name: & str ,
@@ -207,14 +207,16 @@ mod tests {
207207 let file_path = Path :: new ( "./data/iceland.grib" ) ;
208208
209209 let mut handle = CodesFile :: new_from_file ( file_path, product_kind) ?;
210- let mut current_message = handle
210+ let current_message = handle
211211 . ref_message_iter ( )
212212 . next ( ) ?
213213 . context ( "Message not some" ) ?;
214214
215215 let old_key = current_message. read_key_dynamic ( "centre" ) ?;
216216
217- current_message. write_key_unchecked ( "centre" , "cnmc" ) ?;
217+ current_message
218+ . try_clone ( ) ?
219+ . write_key_unchecked ( "centre" , "cnmc" ) ?;
218220
219221 let read_key = current_message. read_key_dynamic ( "centre" ) ?;
220222
@@ -230,14 +232,16 @@ mod tests {
230232 let file_path = Path :: new ( "./data/iceland.grib" ) ;
231233
232234 let mut handle = CodesFile :: new_from_file ( file_path, product_kind) ?;
233- let mut current_message = handle
235+ let current_message = handle
234236 . ref_message_iter ( )
235237 . next ( ) ?
236238 . context ( "Message not some" ) ?;
237239
238240 let old_key = current_message. read_key_dynamic ( "centre" ) ?;
239241
240- current_message. write_key_unchecked ( "centre" , "cnmc" ) ?;
242+ current_message
243+ . try_clone ( ) ?
244+ . write_key_unchecked ( "centre" , "cnmc" ) ?;
241245
242246 current_message. write_to_file ( Path :: new ( "./data/iceland_edit.grib" ) , false ) ?;
243247
0 commit comments