XU XUv0.16.0

#encoding/binary

import: #encoding/binary

counts: 11 functions, 28 methods, 1 types, 0 constants, 0 method sets

Endian integers and uvarint/varint.

struct Endian

XuAPI
pub struct Endian {
    pub little bool
}

Purpose

Structure encapsulating little.

Public fields

little bool
field (bool)

little_endian

XuAPI
pub fn little_endian() Endian

Purpose

Return Little-Endian byte-order codec.

Parameters

No arguments are required.

Returns

Endian — a value of this type

big_endian

XuAPI
pub fn big_endian() Endian

Purpose

Return Big-Endian byte-order codec.

Parameters

No arguments are required.

Returns

Endian — a value of this type

(Endian) get_u16

XuAPI
pub fn (e Endian) get_u16(data &[]int, off int) int

Purpose

Operation on Endian: read u16. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]int
data (read-only borrow; caller keeps the original; type &[]int)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_u32

XuAPI
pub fn (e Endian) get_u32(data &[]int, off int) int

Purpose

Operation on Endian: read u32. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]int
data (read-only borrow; caller keeps the original; type &[]int)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_u64

XuAPI
pub fn (e Endian) get_u64(data &[]int, off int) int

Purpose

Operation on Endian: read u64. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]int
data (read-only borrow; caller keeps the original; type &[]int)
off int
offset (int)

Returns

int — a value of this type

(Endian) put_u16

XuAPI
pub fn (e Endian) put_u16(data $&[]int, off int, v int) int

Purpose

Operation on Endian: put u16. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]int
data (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
v int
value (int)

Returns

int — a value of this type

(Endian) put_u32

XuAPI
pub fn (e Endian) put_u32(data $&[]int, off int, v int) int

Purpose

Operation on Endian: put u32. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]int
data (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
v int
value (int)

Returns

int — a value of this type

(Endian) put_u64

XuAPI
pub fn (e Endian) put_u64(data $&[]int, off int, v int) int

Purpose

Operation on Endian: put u64. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]int
data (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
v int
value (int)

Returns

int — a value of this type

native_endian

XuAPI
pub fn native_endian() Endian

Purpose

Return host native byte-order codec.

Parameters

No arguments are required.

Returns

Endian — a value of this type

(Endian) get_i16

XuAPI
pub fn (e Endian) get_i16(data &[]int, off int) int

Purpose

Operation on Endian: read i16.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]int
data (read-only borrow; caller keeps the original; type &[]int)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_i32

XuAPI
pub fn (e Endian) get_i32(data &[]int, off int) int

Purpose

Operation on Endian: read i32.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]int
data (read-only borrow; caller keeps the original; type &[]int)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_i64

XuAPI
pub fn (e Endian) get_i64(data &[]int, off int) int

Purpose

Operation on Endian: read i64.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]int
data (read-only borrow; caller keeps the original; type &[]int)
off int
offset (int)

Returns

int — a value of this type

(Endian) put_i16

XuAPI
pub fn (e Endian) put_i16(data $&[]int, off int, v int) int

Purpose

Operation on Endian: put i16.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]int
data (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
v int
value (int)

Returns

int — a value of this type

(Endian) put_i32

XuAPI
pub fn (e Endian) put_i32(data $&[]int, off int, v int) int

Purpose

Operation on Endian: put i32.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]int
data (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
v int
value (int)

Returns

int — a value of this type

(Endian) put_i64

XuAPI
pub fn (e Endian) put_i64(data $&[]int, off int, v int) int

Purpose

Operation on Endian: put i64.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]int
data (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
v int
value (int)

Returns

int — a value of this type

put_uvarint

XuAPI
pub fn put_uvarint(x int) string

Purpose

Encode unsigned int as uvarint.

Parameters

x int
value (int)

Returns

string — result string

size_uvarint

XuAPI
pub fn size_uvarint(x int) int

Purpose

Size uvarint.

Parameters

x int
value (int)

Returns

int — a value of this type

uvarint

XuAPI
pub fn uvarint(s &string) int

Purpose

Decode an unsigned uvarint from bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

put_varint

XuAPI
pub fn put_varint(x int) string

Purpose

Encode signed int as ZigZag varint.

Parameters

x int
value (int)

Returns

string — result string

varint

XuAPI
pub fn varint(s &string) int

Purpose

Decode a signed ZigZag varint from bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

s &string
source string (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

size_varint

XuAPI
pub fn size_varint(x int) int

Purpose

Size varint.

Parameters

x int
value (int)

Returns

int — a value of this type

append_uvarint

XuAPI
pub fn append_uvarint(dst string, x int) string

Purpose

Append unsigned uvarint encoding to dst.

Parameters

dst string
destination (string)
x int
value (int)

Returns

string — result string

append_varint

XuAPI
pub fn append_varint(dst string, x int) string

Purpose

Append signed varint encoding to dst.

Parameters

dst string
destination (string)
x int
value (int)

Returns

string — result string

(Endian) get_u16_bytes

XuAPI
pub fn (e Endian) get_u16_bytes(data &[]u8, off int) int

Purpose

Operation on Endian: read u16 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_u32_bytes

XuAPI
pub fn (e Endian) get_u32_bytes(data &[]u8, off int) int

Purpose

Operation on Endian: read u32 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_u64_bytes

XuAPI
pub fn (e Endian) get_u64_bytes(data &[]u8, off int) int

Purpose

Operation on Endian: read u64 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

int — a value of this type

(Endian) put_u16_bytes

XuAPI
pub fn (e Endian) put_u16_bytes(data $&[]u8, off int, value int) int

Purpose

Operation on Endian: put u16 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value int
value (int)

Returns

int — a value of this type

(Endian) put_u32_bytes

XuAPI
pub fn (e Endian) put_u32_bytes(data $&[]u8, off int, value int) int

Purpose

Operation on Endian: put u32 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value int
value (int)

Returns

int — a value of this type

(Endian) put_u64_bytes

XuAPI
pub fn (e Endian) put_u64_bytes(data $&[]u8, off int, value int) int

Purpose

Operation on Endian: put u64 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value int
value (int)

Returns

int — a value of this type

(Endian) get_i16_bytes

XuAPI
pub fn (e Endian) get_i16_bytes(data &[]u8, off int) int

Purpose

Operation on Endian: read i16 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_i32_bytes

XuAPI
pub fn (e Endian) get_i32_bytes(data &[]u8, off int) int

Purpose

Operation on Endian: read i32 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

int — a value of this type

(Endian) get_i64_bytes

XuAPI
pub fn (e Endian) get_i64_bytes(data &[]u8, off int) int

Purpose

Operation on Endian: read i64 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

int — a value of this type

(Endian) put_i16_bytes

XuAPI
pub fn (e Endian) put_i16_bytes(data $&[]u8, off int, value int) int

Purpose

Operation on Endian: put i16 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value int
value (int)

Returns

int — a value of this type

(Endian) put_i32_bytes

XuAPI
pub fn (e Endian) put_i32_bytes(data $&[]u8, off int, value int) int

Purpose

Operation on Endian: put i32 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value int
value (int)

Returns

int — a value of this type

(Endian) put_i64_bytes

XuAPI
pub fn (e Endian) put_i64_bytes(data $&[]u8, off int, value int) int

Purpose

Operation on Endian: put i64 bytes. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value int
value (int)

Returns

int — a value of this type

(Endian) get_f32

XuAPI
pub fn (e Endian) get_f32(data &[]u8, off int) f64

Purpose

Float interfaces operate on tight []u8. Binary32 is rounded from / expanded to Xu f64; binary64 preserves every bit, including signed zero and NaNs. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

f64 — a value of this type

(Endian) get_f64

XuAPI
pub fn (e Endian) get_f64(data &[]u8, off int) f64

Purpose

Operation on Endian: read f64. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data &[]u8
data (read-only borrow; caller keeps the original; type &[]u8)
off int
offset (int)

Returns

f64 — a value of this type

(Endian) put_f32

XuAPI
pub fn (e Endian) put_f32(data $&[]u8, off int, value f64) int

Purpose

Operation on Endian: put f32. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value f64
value (f64)

Returns

int — a value of this type

(Endian) put_f64

XuAPI
pub fn (e Endian) put_f64(data $&[]u8, off int, value f64) int

Purpose

Operation on Endian: put f64. Throws on failure; handle the error or propagate it to the caller.

Parameters

e Endian
The Endian instance used by this call (value receiver).
data $&[]u8
data (exclusive borrow; may modify the original; type $&[]u8)
off int
offset (int)
value f64
value (f64)

Returns

int — a value of this type