hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

endian.ha (763B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 // The set of functions used for endian-aware encoding.
      5 export type endian = struct {
      6 	getu16: *fn(buf: []u8) u16,
      7 	putu16: *fn(buf: []u8, in: u16) void,
      8 	getu32: *fn(buf: []u8) u32,
      9 	putu32: *fn(buf: []u8, in: u32) void,
     10 	getu64: *fn(buf: []u8) u64,
     11 	putu64: *fn(buf: []u8, in: u64) void,
     12 };
     13 
     14 // Big endian; MSB first.
     15 export const big: endian = endian {
     16 	getu16 = &begetu16,
     17 	putu16 = &beputu16,
     18 	getu32 = &begetu32,
     19 	putu32 = &beputu32,
     20 	getu64 = &begetu64,
     21 	putu64 = &beputu64,
     22 };
     23 
     24 // Little endian; LSB first.
     25 export const little: endian = endian {
     26 	getu16 = &legetu16,
     27 	putu16 = &leputu16,
     28 	getu32 = &legetu32,
     29 	putu32 = &leputu32,
     30 	getu64 = &legetu64,
     31 	putu64 = &leputu64,
     32 };