Skip to content

Latest commit

 

History

History
587 lines (377 loc) · 13.8 KB

File-std-bytes-ml-1351945333.md

File metadata and controls

587 lines (377 loc) · 13.8 KB

std/bytes.ml

Home · Files

Provides the std bytes package.

Package: std.bytes

Reachable from entry: no

Imports

Declarations

alloc

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

allocFill

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

BYTES_ERR

const BYTES_ERR = 211

Track the bytes err value used by this standard-library module.

Source: std/bytes.ml:22

compare

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

concat

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

copy

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

ctEquals

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

decodeUtf16Z

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

decodeUtf8

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

decodeUtf8OrError

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

decodeUtf8Z

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

endsWith

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

equals

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

fill

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

fromHex

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

fromHexOrError

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

indexOf

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

lastIndexOf

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

readU16BE

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

readU16LE

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

readU32BE

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

readU32LE

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

readU8

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

startsWith

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

sub

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

subOrError

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

toHex

function toHex(b)

Encode bytes as lowercase hexadecimal text.

Parameter Type Default Description
b dynamic — Second input value.

Source: std/bytes.ml:352

writeU16BE

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

writeU16LE

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

writeU32BE

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

writeU32LE

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

writeU8

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

xor

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

xorInPlace

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