Manuscript Documentation
v0.1.0

@std/binary.ms#

Import each required symbol with import Name from "@std/binary.ms".

BinaryError Alternative#

Errors returned when a byte range or numeric representation is invalid.

Manuscript
type BinaryError:
    case InvalidInput
    case OutOfRange
Manuscript
impl Error for BinaryError:
    fn message() -> String:

BinaryError.InvalidInput#

Integer width is unsupported; the native codec accepts only 1, 2, 4 or 8 bytes.

Manuscript
case InvalidInput

BinaryError.OutOfRange#

A read crosses the byte buffer or a number cannot fit the requested signedness/width or result type.

Manuscript
case OutOfRange

BinaryError.Error.message#

Returns a binary-prefixed diagnostic without echoing source bytes or numeric input.

Manuscript
fn message() -> String:

read_float Function#

Reads a 64-bit floating-point value (binary64, 8 bytes) at offset using the selected byte order.

Manuscript
fn read_float(data: Bytes, offset: Int, little_endian: Bool) -> Result[Float, BinaryError]:

read_integer Function#

Reads an integer of width bytes. Signed values use two’s-complement encoding.

Manuscript
fn read_integer(data: Bytes, offset: Int, width: Int, signed: Bool, little_endian: Bool) -> Result[Int, BinaryError]:

write_float Function#

Encodes a 64-bit floating-point value (binary64) as 8 bytes using the selected byte order.

Manuscript
fn write_float(value: Float, little_endian: Bool) -> Bytes:

write_integer Function#

Encodes an integer into width bytes, returning an error when it does not fit.

Manuscript
fn write_integer(value: Int, width: Int, signed: Bool, little_endian: Bool) -> Result[Bytes, BinaryError]: