You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<dtype> is one of u8 | u16 | u32 | i32 | i64 | f16 | f32 | f64 (or bool/string for the BE family). Almide Int is i64 and Float is f64; smaller widths are sign- or zero-extended on read and truncated on write.
Construction & inspection
Signature
Purpose
bytes.new(len: Int) -> Bytes
Allocate len zeroed bytes
bytes.from_list(xs: List[Int]) -> Bytes
From a list of byte values
bytes.from_string(s: String) -> Bytes
UTF-8 view of a string (zero-copy)
bytes.to_list(b) -> List[Int]
Materialise as a list
bytes.len(b) -> Int
Length
bytes.is_empty(b) -> Bool
Length == 0
bytes.get(b, i) -> Option[Int]
Single byte
bytes.get_or(b, i, default) -> Int
Single byte with fallback
Slicing & combining
Signature
Purpose
bytes.slice(b, start, end) -> Bytes
Half-open slice
bytes.concat(a, b) -> Bytes
Concatenate
bytes.repeat(b, n) -> Bytes
Repeat n times
bytes.set(b, i, val) -> Bytes
Replace one byte
bytes.push(b, val)
Append one byte (mutates)
bytes.clear(b)
Truncate to length 0 (mutates)
Little-endian readers (single value)
Signature
Width
bytes.read_u8(b, pos)
1 byte
bytes.read_u16_le(b, pos)
2 bytes
bytes.read_u32_le(b, pos)
4 bytes (zero-extended)
bytes.read_i32_le(b, pos)
4 bytes (sign-extended)
bytes.read_i64_le(b, pos)
8 bytes
bytes.read_f16_le(b, pos)
2 bytes → Float (IEEE-754 half)
bytes.read_f32_le(b, pos)
4 bytes → Float (promoted)
bytes.read_f64_le(b, pos)
8 bytes → Float
Little-endian readers (bulk arrays)
Each returns a List[T] — one native call beats count Almide-side reads.
Signature
Element width
bytes.read_i32_le_array(b, pos, count)
4 bytes → List[Int]
bytes.read_u32_le_array(b, pos, count)
4 bytes → List[Int]
bytes.read_i64_le_array(b, pos, count)
8 bytes → List[Int]
bytes.read_f16_le_array(b, pos, count)
2 bytes → List[Float]
bytes.read_f32_le_array(b, pos, count)
4 bytes → List[Float]
bytes.read_f64_le_array(b, pos, count)
8 bytes → List[Float]
Little-endian writers
set_*_le overwrites at a fixed position; append_*_le grows the buffer.
Signature
Effect
bytes.set_u8(b, pos, val)
Overwrite 1 byte
bytes.set_u16_le(b, pos, val)
Overwrite 2 bytes
bytes.set_u32_le(b, pos, val)
Overwrite 4 bytes
bytes.set_i32_le(b, pos, val)
Overwrite 4 bytes
bytes.set_i64_le(b, pos, val)
Overwrite 8 bytes
bytes.set_f32_le(b, pos, val)
Overwrite 4 bytes (demoted from f64)
bytes.set_f64_le(b, pos, val)
Overwrite 8 bytes
bytes.append_u8(b, val)
Append 1 byte
bytes.append_u16_le(b, val)
Append 2 bytes
bytes.append_u32_le(b, val)
Append 4 bytes
bytes.append_i32_le(b, val)
Append 4 bytes
bytes.append_i64_le(b, val)
Append 8 bytes
bytes.append_f32_le(b, val)
Append 4 bytes (demoted from f64)
bytes.append_f64_le(b, val)
Append 8 bytes
Big-endian (network protocols)
Single-value readers (returns 0 on out-of-bounds — see roadmap for _at variants):
Signature
Width
bytes.read_u32_be(b, pos)
4 bytes
bytes.read_i32_be(b, pos)
4 bytes (sign-extended)
bytes.read_i64_be(b, pos)
8 bytes
bytes.read_f32_be(b, pos)
4 bytes → Float
bytes.read_f64_be(b, pos)
8 bytes → Float
bytes.read_string_be(b, pos)
length-prefixed string
bytes.read_bool(b, pos)
1-byte bool
Bulk readers (symmetric to LE):
Signature
Element width
bytes.read_u32_be_array(b, pos, count)
4 bytes → List[Int]
bytes.read_i32_be_array(b, pos, count)
4 bytes → List[Int]
bytes.read_i64_be_array(b, pos, count)
8 bytes → List[Int]
bytes.read_f32_be_array(b, pos, count)
4 bytes → List[Float]
bytes.read_f64_be_array(b, pos, count)
8 bytes → List[Float]
Appenders (preferred). The write_*_be family is the older spelling and remains as an alias.