[−][src]Trait byte_struct::ByteStructImpl
A type that can be packed into or unpacked from raw bytes under given default byte order.
This trait is implemented for most numeric primitive types,
except for bool, char, isize and usize.
This is also implemented for array types whose element type implements ByteStructImpl
and whose size is between 1 and 32 (inclusive).
This trait is also implemented for struct with either #[derive(ByteStructLE)] or #[derive(ByteStructBE)].
Members in this trait, except for BYTE_LEN, are meant to be used by byte_struct internal only.
They do not do what one might expect:
the byte orders specified in read_*_bytes/write_*_bytes functions are only default byte order.
The default byte order is only repected when the type itself does not carry byte order specification
(e.g. primitive types). In contrast, since ByteStruct-derived structures always have byte order specification,
the default byte order has no effect on them, and the three versions of read / write functions,
_le_, _be_ and no-spec from ByteStruct, behave exactly the same.
In some cases, one might want to implement ByteStructImpl for custom types
so that they can be members of ByteStruct-derived structures.
Associated Constants
Loading content...Required methods
fn write_le_bytes(&self, bytes: &mut [u8])
Packs the object into raw bytes with little-endian as the default byte order
fn read_le_bytes(bytes: &[u8]) -> Self
Unpacks raw bytes into a new object with little-endian as the default byte order
fn write_be_bytes(&self, bytes: &mut [u8])
Packs the object into raw bytes with big-endian as the default byte order
fn read_be_bytes(bytes: &[u8]) -> Self
Unpacks raw bytes into a new object with big-endian as the default byte order