package core:encoding/endian

⌘K
Ctrl+K
or
/

    Overview

    Package endian implements a simple translation between bytes and numbers with specific endian encodings.

    buf: [100]u8 put_u16(buf[:], .Little, 16) or_return

    You may ask yourself, why isn't byte_order platform Endianness by default, so we can write: put_u16(buf[:], 16) or_return

    The answer is that very few file formats are written in native/platform endianness. Most of them specify the endianness of each of their fields, or use a header field which specifies it for the entire file.

    e.g. a file which specifies it at the top for all fields could do this: file_order := .Little if buf[0] == 0 else .Big field := get_u16(buf[1:], file_order) or_return

    If on the other hand a field is always Big-Endian, you're wise to explicitly state it for the benefit of the reader, be that your future self or someone else.

    field := get_u16(buf[:], .Big) or_return

    Types

    Constants

    PLATFORM_BYTE_ORDER ¶

    PLATFORM_BYTE_ORDER :: Byte_Order.Little when ODIN_ENDIAN == .Little else Byte_Order.Big

    Variables

    This section is empty.

    Procedures

    get_f16 ¶

    get_f16 :: proc "contextless" (b: []u8, order: Byte_Order) -> (f16, bool) {…}

    get_f32 ¶

    get_f32 :: proc "contextless" (b: []u8, order: Byte_Order) -> (f32, bool) {…}

    get_f64 ¶

    get_f64 :: proc "contextless" (b: []u8, order: Byte_Order) -> (f64, bool) {…}

    get_i16 ¶

    get_i16 :: proc "contextless" (b: []u8, order: Byte_Order) -> (i16, bool) {…}

    get_i32 ¶

    get_i32 :: proc "contextless" (b: []u8, order: Byte_Order) -> (i32, bool) {…}

    get_i64 ¶

    get_i64 :: proc "contextless" (b: []u8, order: Byte_Order) -> (i64, bool) {…}

    get_u16 ¶

    get_u16 :: proc "contextless" (b: []u8, order: Byte_Order) -> (v: u16, ok: bool) {…}

    get_u32 ¶

    get_u32 :: proc "contextless" (b: []u8, order: Byte_Order) -> (v: u32, ok: bool) {…}

    get_u64 ¶

    get_u64 :: proc "contextless" (b: []u8, order: Byte_Order) -> (v: u64, ok: bool) {…}

    put_f16 ¶

    put_f16 :: proc "contextless" (b: []u8, order: Byte_Order, v: f16) -> bool {…}

    put_f32 ¶

    put_f32 :: proc "contextless" (b: []u8, order: Byte_Order, v: f32) -> bool {…}

    put_f64 ¶

    put_f64 :: proc "contextless" (b: []u8, order: Byte_Order, v: f64) -> bool {…}

    put_i16 ¶

    put_i16 :: proc "contextless" (b: []u8, order: Byte_Order, v: i16) -> bool {…}

    put_i32 ¶

    put_i32 :: proc "contextless" (b: []u8, order: Byte_Order, v: i32) -> bool {…}

    put_i64 ¶

    put_i64 :: proc "contextless" (b: []u8, order: Byte_Order, v: i64) -> bool {…}

    put_u16 ¶

    put_u16 :: proc "contextless" (b: []u8, order: Byte_Order, v: u16) -> bool {…}

    put_u32 ¶

    put_u32 :: proc "contextless" (b: []u8, order: Byte_Order, v: u32) -> bool {…}

    put_u64 ¶

    put_u64 :: proc "contextless" (b: []u8, order: Byte_Order, v: u64) -> bool {…}

    unchecked_get_u16be ¶

    unchecked_get_u16be :: proc "contextless" (b: []u8) -> u16 {…}

    unchecked_get_u16le ¶

    unchecked_get_u16le :: proc "contextless" (b: []u8) -> u16 {…}

    unchecked_get_u32be ¶

    unchecked_get_u32be :: proc "contextless" (b: []u8) -> u32 {…}

    unchecked_get_u32le ¶

    unchecked_get_u32le :: proc "contextless" (b: []u8) -> u32 {…}

    unchecked_get_u64be ¶

    unchecked_get_u64be :: proc "contextless" (b: []u8) -> u64 {…}

    unchecked_get_u64le ¶

    unchecked_get_u64le :: proc "contextless" (b: []u8) -> u64 {…}

    unchecked_put_u16be ¶

    unchecked_put_u16be :: proc "contextless" (b: []u8, v: u16) {…}

    unchecked_put_u16le ¶

    unchecked_put_u16le :: proc "contextless" (b: []u8, v: u16) {…}

    unchecked_put_u32be ¶

    unchecked_put_u32be :: proc "contextless" (b: []u8, v: u32) {…}

    unchecked_put_u32le ¶

    unchecked_put_u32le :: proc "contextless" (b: []u8, v: u32) {…}

    unchecked_put_u64be ¶

    unchecked_put_u64be :: proc "contextless" (b: []u8, v: u64) {…}

    unchecked_put_u64le ¶

    unchecked_put_u64le :: proc "contextless" (b: []u8, v: u64) {…}

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-04 (vendor "odin") Windows_amd64 @ 2024-04-26 21:08:58.370938900 +0000 UTC