Macro flatdata::write_bytes [−][src]
macro_rules! write_bytes { ($T:tt; $value:expr, $data:expr, $offset:expr, $num_bits:expr) => { ... }; ($T:tt; $value:expr, $data:expr, $offset:expr) => { ... }; ($T:tt; $value:expr, $data:expr) => { ... }; }
Writes specified number of bits of a given value to a slice at a specified offset in portable way.
This macro is used by ArchiveBuilder
to serialize data to storage. It
ensures that the data is written in a portable way independent of the
platform and compiler. To read the data written by this macro, use
read_bytes
.
The maximum amount of bits which can be written is 64. If $num_bits
is
not specified, std::mem::size_of::<T>
is used.
Arguments
T
– integer type of the value to write (signed or unsigned),value
– value to write,data
– slice for writing to,offset
– offset in bits in the slice, where the value should be written,num_bits
– how many bits of the value to write.