Bytes

Bytes

Opaque byte sequences for the BEAM target (target = "erlang").

The JavaScript target keeps using the client platform Bytes package. This is not the browser file-picker API; see File for filesystem tasks.

Types

Bytes

type Bytes = Bytes

A sequence of bytes (OTP binary under the hood).

Examples

width (Bytes.Encode.encode (Bytes.Encode.string "hi")) == 2

Endianness

type Endianness
= LE
| BE

Byte order for multi-byte integers and floats.

BE is network / "obvious" order; LE is Intel-style shuffled order.

Examples

Bytes.Encode.encode (Bytes.Encode.unsignedInt16 BE 7)
-- two bytes: 00 07

Bytes.Encode.encode (Bytes.Encode.unsignedInt16 LE 7)
-- two bytes: 07 00

Values

width

width : Bytes -> Int

Number of bytes in the sequence.

Examples

width (Bytes.Encode.encode (Bytes.Encode.unsignedInt8 1)) == 1
width (Bytes.Encode.encode (Bytes.Encode.string "hi")) == 2

getHostEndianness

getHostEndianness : Task x Endianness

Host machine endianness (usually LE on common CPUs).

Examples

-- Task that resolves to LE or BE
getHostEndianness