# `Ksc.Stream`
[🔗](https://github.com/PJUllrich/ksc/blob/v0.1.0/lib/ksc/stream.ex#L1)

Lightweight runtime for Kaitai Struct generated parsers.

# `align_to_byte`

Align bit state back to byte boundary, returning binary.

# `decode_string`

Decode a binary from the given encoding to a UTF-8 string.

# `floor_div`

Floor division (Python-style: result rounds towards negative infinity).

# `floor_mod`

Floor modulo (Python-style: result has same sign as divisor).

# `kaitai_add`

KSY add operator - string concat or arithmetic add.

# `kaitai_at`

Access element at index (supports both lists and binaries).

# `kaitai_first`

Get first element of a list or first byte of a binary.

# `kaitai_io_size`

Get the IO stream size for a parsed object. Uses stored _io_size metadata.

# `kaitai_last`

Get last element of a list or last byte of a binary.

# `kaitai_length`

Length of a string (character count) or size of a list/binary.

# `kaitai_max`

Get maximum value from a list or binary.

# `kaitai_min`

Get minimum value from a list or binary (treating bytes as values).

# `kaitai_size`

Get size of a list or byte_size of a binary.

# `kaitai_sizeof`

Get the sizeof a parsed type or field. Uses stored _sizeof metadata.

# `process_rotate_left`

Rotate each byte left by amount bits.

# `process_xor`

XOR each byte in data with a single-byte key.

# `process_zlib`

Zlib decompress.

# `read_bits`

Read N bits from a binary, big-endian bit order.
Returns {value, rest_binary}.

# `read_bits_be`

Read N bits in big-endian bit order from a {bits_remaining, bit_count, binary} tuple or binary.
Returns {value, {bits_remaining, bit_count, rest_binary}}.
This supports consecutive bit reads without byte-realignment.

# `read_bits_le`

Read N bits in little-endian bit order.

# `read_strz`

Read a null-terminated string from binary, returning {string, rest}.

# `read_strz_consume`

Read a null-terminated string with consume control.

# `read_strz_enc`

Read a null-terminated string from binary with encoding support.

# `read_terminated`

Read bytes from binary until a terminator byte is found.
Returns {bytes_read, rest_of_binary}.

- consume: if true (default), the terminator byte is consumed from the stream
- include: if true, the terminator byte is included in the returned value

# `repeat_eos`

Parse items repeatedly until binary is exhausted.

# `repeat_eos_bits`

Parse bit items repeatedly until binary is exhausted.

# `repeat_eos_idx`

Parse items repeatedly until binary is exhausted, with index tracking.

# `repeat_until`

Parse items repeatedly until condition is met.

# `repeat_until_check`

Parse items until parse fn signals done (returns {item, rest, true}).

# `repeat_until_check_idx`

Parse items until parse fn signals done, with index tracking.

# `repeat_until_idx`

Parse items repeatedly until condition is met, with index tracking.

# `strip_pad_right`

Strip trailing pad bytes from binary.

# `terminate_and_pad`

Terminate at terminator, then strip pad bytes only when terminator was NOT found.

# `terminate_at`

Terminate binary at first occurrence of byte.

# `to_i`

Convert value to integer (like Ruby's .to_i).

# `to_i`

Convert value to integer with enum reverse lookup.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
