sysfunc-byteorder
This repository contains basic byte order support code for compile-time assessment and may use pre-compiled models derived from a given platform.
Originally this was designed to be significantly more complex, but it has been moved into other crates due to the massive size and weight bearing down on it. This now uses const fn
and macro work to present byte order for:
u8
;u16
;u32
;u64
;u128
(with feature 'enable-128').The signed types should function in the same manner (as should floating point types, all things considered).
Various tricks cannot currently be employed, but the tricks here should suffice for most purposes (where the models are known but may be variable).
is_big_endian
: tests whether or not the platform endian is big/network byte order (disabled with no-core
);is_little_endian
: tests whether or not the platform endian is little endian byte order (disabled with no-core
);get_byte_order_128
: returns u128 with bytes ranging from 0 through 15, indicating the order they should be loaded off the wire (or onto).get_byte_order_64
: returns u64 with bytes ranging from 0 through 7, indicating the order they should be loaded off the wire (or onto).get_byte_order_32
: returns u32 with bytes ranging from 0 through 3, indicating the order they should be loaded off the wire (or onto).get_byte_order_16
: returns u16 with bytes ranging from 0 through 1, indicating the order they should be loaded off the wire (or onto).default
: enables nothing (standard behaviour for my crates);no-core
: enables #![no_core]
;enable-128
: enables 128-bit types.no-core
will require language features (copy
, sized
, and freeze
), so expect that to be a problem if you are missing them. It will also require you implement various basic language features (which are this time aren't exactly a small ask due to const fn
restrictions); at this stage it appears just to be Shl
and BitOr
.
This project is licensed under the ISC Licence. See LICENCE
.