Std.BitString
Operations on raw binary data (Erlang bitstrings).
Functions
size
fun size : (bs: BitString) -> IntReturns the size of the bitstring in bytes.
from_list
fun from_list : (bytes: List Int) -> BitStringCreates a bitstring from a list of byte values (0-255).
to_list
fun to_list : (bs: BitString) -> List IntConverts a bitstring to a list of byte values.
from_string
fun from_string : (s: String) -> BitStringCreates a bitstring from a UTF-8 encoded string. This is a zero-cost operation since Dylan strings are already UTF-8 binaries.
to_string
fun to_string : (bs: BitString) -> Result String StringAttempts to decode a bitstring as a UTF-8 string. Returns Err if the bitstring is not valid UTF-8.
at
fun at : (index: Int) -> (bs: BitString) -> Maybe IntReturns the byte at the given zero-based index, or Nothing if out of bounds.
slice
fun slice : (start: Int) -> (len: Int) -> (bs: BitString) -> BitStringExtracts a sub-bitstring starting at position for length bytes.
append
fun append : (a: BitString) -> (b: BitString) -> BitStringAppends two bitstrings. Also available via the <> operator.
zeroes
fun zeroes : (n: Int) -> BitStringCreates a bitstring of the given size filled with zero bytes.
from_byte
fun from_byte : (byte: Int) -> BitStringCreates a single-byte bitstring from an integer (0-255).
encode_int
fun encode_int : (width: Int) -> (value: Int) -> BitStringEncodes an integer as a big-endian bitstring of the given byte width.
decode_int
fun decode_int : (bs: BitString) -> IntDecodes a big-endian integer from a bitstring.
encode_int_little
fun encode_int_little : (width: Int) -> (value: Int) -> BitStringEncodes an integer as a little-endian bitstring of the given byte width.
decode_int_little
fun decode_int_little : (bs: BitString) -> IntDecodes a little-endian integer from a bitstring.
is_empty
fun is_empty : BitString -> BoolReturns True if the bitstring is empty (zero bytes).