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::Write
trait.$key
: The key to write. This can beSome([u8; N])
whereN
is the length of the key, orNone
to 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);