macro_rules! write_data {
($writer:expr, $key:expr, $len:literal) => { ... };
}Expand description
Writes data to a stream.
This macro writes the key to the stream if it is present. If the key is None,
the macro writes padding instead, ensuring the correct number of bytes is always written.
§Parameters:
$writer: The writer where the key (or padding) should be written. Must implement thestd::io::Writetrait.$key: The key to write. This can beSome([u8; N])whereNis the length of the key, orNoneto indicate that the key is missing.$len: The length of the key (or the padding) in bytes. This will determine how many bytes to write if the key is absent.
§Example:
let mut buffer = Vec::new();
let key: Option<[u8; 10]> = Some([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
write_data!(buffer, key, 10);