Skip to content

0.4.0

Choose a tag to compare

@webmaster128 webmaster128 released this 10 Feb 19:51
· 39 commits to main since this release

append_repeated_string got a generic element types

The list type of append_repeated_string changed from &[&str] to &[S] with the generic list element type S: AsRef<str>. This supports all previous types and many more. Especially owned string lists like Vec<String> can now be used directly:

let owned: Vec<String> = vec![
    "green".to_string(),
    "orange".to_string(),
];
let serialized = Anybuf::new()
    .append_repeated_string(4, &owned)
    .into_vec();

Before 0.4.0 you had to create a new list of references in order to call append_repeated_string.

In some cases you need to add an explicit generic type because the type can't be inferred anymore:

 let data = Anybuf::new()
     .append_string(1, "no messages")
-    .append_repeated_string(9, &[]);
+    .append_repeated_string::<&str>(9, &[]);

append_repeated_bytes got a generic element types

The list type of append_repeated_bytes changed from &[&[u8]] to &[B] with the generic list element type B: AsRef<[u8]>. This supports all previous types and many more. Especially owned data lists like Vec<Vec<u8>> can now be used directly:

let owned: Vec<Vec<u8>> = vec![
    vec![1u8; 10],
    vec![2u8; 10],
    vec![3u8; 10],
];
let serialized = Anybuf::new()
    .append_repeated_bytes(5, &owned)
    .into_vec();

Before 0.4.0 you had to create a new list of slice references in order to call append_repeated_bytes.

In some cases you need to add an explicit generic type because the type can't be inferred anymore:

 let data = Anybuf::new()
     .append_string(1, "no messages")
-    .append_repeated_bytes(10, &[]);
+    .append_repeated_bytes::<&[u8]>(10, &[]);

append_repeated_message get a generic element types

The list type of append_repeated_message changed from &[&Anybuf] to &[M] with the generic list element type M: AsRef<Anybuf>. This supports all previous types and many more. Especially owned data lists like Vec<Anybuf> can now be used directly:

let owned: Vec<Anybuf> = vec![
    Anybuf::new().append_uint32(1, 1),
    Anybuf::new().append_uint32(1, 2),
    Anybuf::new().append_uint32(1, 3),
];
let serialized = Anybuf::new()
    .append_repeated_message(11, &owned)
    .into_vec();

Before 0.4.0 you had to create a new list of references in order to call append_repeated_message.

In some cases you need to add an explicit generic type because the type can't be inferred anymore:

 let data = Anybuf::new()
     .append_string(1, "no messages")
-    .append_repeated_message(11, &[]);
+    .append_repeated_message::<&Anybuf>(11, &[]);