macro_rules! serialize_into {
($buffer:expr, length=$length:ident, $($member:expr),+) => { ... };
($buffer:expr, $($member:expr),+) => { ... };
}Expand description
Serializes a series of variables into the given buffer.
An optional length parameter can be specified to serialize the variables using serialize_len.
§Performance Considerations
This macro is provided simply as a convenience for implementing the Serialize trait.
It uses tuples to serialize the variables into the buffer, which may not work well in every situation.
§Examples
use rsomeip_bytes::{BytesMut, Serialize, serialize_into};
let [a, b, c, d] = [1u8, 2, 3, 4];
let mut buffer = BytesMut::new();
let mut size = 0;
size += serialize_into!(&mut buffer, a, b).expect("should serialize");
size += serialize_into!(&mut buffer, length = U8, c, d).expect("should serialize");
assert_eq!(size, 5);
assert_eq!(buffer[..], [1u8, 2, 2, 3, 4]);