Provides the std bytes package.
Package: std.bytes
Reachable from entry: no
std/encoding/hex.mlashx→ std/encoding/hex.ml
function alloc(size)Std.bytes Bytes helpers built on top of the built-in bytes type and operations.
| Parameter | Type | Default | Description |
|---|---|---|---|
size |
dynamic |
— | Value supplied for size. |
Source: std/bytes.ml:38
function allocFill(size, fill)Allocate size bytes initialized to the low eight bits of fill.
| Parameter | Type | Default | Description |
|---|---|---|---|
size |
dynamic |
— | Value supplied for size. |
fill |
dynamic |
— | Value supplied for fill. |
Source: std/bytes.ml:51
const BYTES_ERR = 211Track the bytes err value used by this standard-library module.
Source: std/bytes.ml:22
function compare(a, b)Return a lexicographic three-way comparison result.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:340
function concat(a, b)Concatenate two byte sequences into newly allocated storage.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:133
function copy(b)Return a detached copy of a bytes value.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:66
function ctEquals(a, b)Compare equal-length sequences without data-dependent early exit.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:159
function decodeUtf16Z(b)Decode little-endian UTF-16 bytes up to the first zero code unit.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:405
function decodeUtf8(b)Decode UTF-8 bytes, returning void on invalid input.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:378
function decodeUtf8OrError(b)Decode UTF-8 bytes, preserving validation failures as errors.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:384
function decodeUtf8Z(b)Decode UTF-8 bytes up to the first zero terminator.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:398
function endsWith(b, suffix)Report whether b ends with suffix.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
suffix |
dynamic |
— | Value supplied for suffix. |
Source: std/bytes.ml:245
function equals(a, b)Compare two byte sequences with ordinary early-exit semantics.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:146
function fill(b, value)Replace every byte in b with the low eight bits of value.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
value |
dynamic |
— | Value to process. |
Source: std/bytes.ml:213
function fromHex(s)Decode hexadecimal text, returning void on invalid input.
| Parameter | Type | Default | Description |
|---|---|---|---|
s |
dynamic |
— | Value supplied for s. |
Source: std/bytes.ml:358
function fromHexOrError(s)Decode hexadecimal text, preserving validation failures as errors.
| Parameter | Type | Default | Description |
|---|---|---|---|
s |
dynamic |
— | Value supplied for s. |
Source: std/bytes.ml:364
function indexOf(hay, needle, start)Find the first needle occurrence at or after start, or return -1.
| Parameter | Type | Default | Description |
|---|---|---|---|
hay |
dynamic |
— | Value supplied for hay. |
needle |
dynamic |
— | Value supplied for needle. |
start |
dynamic |
— | Value supplied for start. |
Source: std/bytes.ml:311
function lastIndexOf(hay, needle)Find the final needle occurrence, or return -1.
| Parameter | Type | Default | Description |
|---|---|---|---|
hay |
dynamic |
— | Value supplied for hay. |
needle |
dynamic |
— | Value supplied for needle. |
Source: std/bytes.ml:327
function readU16BE(b, off)Read an unsigned big-endian 16-bit integer.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
Source: std/bytes.ml:553
function readU16LE(b, off)Read an unsigned little-endian 16-bit integer.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
Source: std/bytes.ml:534
function readU32BE(b, off)Read an unsigned big-endian 32-bit integer.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
Source: std/bytes.ml:649
function readU32LE(b, off)Read an unsigned little-endian 32-bit integer.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
Source: std/bytes.ml:628
function readU8(b, off)Read one unsigned byte or return a range/type error.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
Source: std/bytes.ml:465
function startsWith(b, prefix)Report whether b begins with prefix.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
prefix |
dynamic |
— | Value supplied for prefix. |
Source: std/bytes.ml:232
function sub(b, offset, length)Return a clamped slice, or void when the input is not bytes.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
offset |
dynamic |
— | Zero-based starting offset. |
length |
dynamic |
— | Number of elements or bytes to process. |
Source: std/bytes.ml:77
function subOrError(b, offset, length)Return an exact validated slice or a descriptive error value.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
offset |
dynamic |
— | Zero-based starting offset. |
length |
dynamic |
— | Number of elements or bytes to process. |
Source: std/bytes.ml:95
function toHex(b)Encode bytes as lowercase hexadecimal text.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:352
function writeU16BE(b, off, value)Write an unsigned 16-bit integer in big-endian order.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
value |
dynamic |
— | Value to process. |
Source: std/bytes.ml:509
function writeU16LE(b, off, value)Write an unsigned 16-bit integer in little-endian order.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
value |
dynamic |
— | Value to process. |
Source: std/bytes.ml:483
function writeU32BE(b, off, value)Write an unsigned 32-bit integer in big-endian order.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
value |
dynamic |
— | Value to process. |
Source: std/bytes.ml:601
function writeU32LE(b, off, value)Write an unsigned 32-bit integer in little-endian order.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
value |
dynamic |
— | Value to process. |
Source: std/bytes.ml:573
function writeU8(b, off, value)Write one unsigned byte and return the next offset.
| Parameter | Type | Default | Description |
|---|---|---|---|
b |
dynamic |
— | Second input value. |
off |
dynamic |
— | Value supplied for off. |
value |
dynamic |
— | Value to process. |
Source: std/bytes.ml:441
function xor(a, b)Return the bytewise XOR of two equal-length sequences.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:670
function xorInPlace(a, b)XOR b into a in place; both sequences must have equal length.
| Parameter | Type | Default | Description |
|---|---|---|---|
a |
dynamic |
— | First input value. |
b |
dynamic |
— | Second input value. |
Source: std/bytes.ml:709