Expand description
This crate defines a buffer data structure optimized to be written to and read from standard
Vec
s. DataBuffer
is particularly useful when dealing with data whose type is determined at
run time. Note that data is stored in the underlying byte buffers in native endian form, thus
requesting typed data from a buffer on a platform with different endianness is unsafe.
§Caveats
DataBuffer
doesn’t support zero-sized types.
Re-exports§
pub use reinterpret;
Modules§
- macros
- Utility macros for code generation.
Macros§
- call_
numeric_ buffer_ fn - Applies
$fn
to anDataBuffer
mapping valid numeric data types by corresponding generic parameters. For example, passing anDataBuffer
containing data of typeu8
will cause this macro to call$fn
with type parameteru8
like$fn::<u8>(buffer)
.
Structs§
- Data
Buffer - Buffer of data. The data is stored as an array of bytes (
Vec<u8>
).DataBuffer
keeps track of the type stored within via an explicitTypeId
member. This allows one to hide the type from the compiler and check it only when necessary. It is particularly useful when the type of data is determined at runtime (e.g. when parsing numeric data).