Skip to content
Konjure / spatial intelligence

Bin

← Builtin reference

Immutable bytes without an implied text encoding.

Signature

Cloning shares a packed Arc allocation. bytes constructs Bin from List[u8], Str.utf8 encodes text, and Bin.decode validates UTF-8 with a Res result. Indexing returns Res[u8, DataError]; slicing produces Res[Bin, DataError]. Concatenation creates independent data and respects byte limits.

Methods

len

len() -> f64

Returns the receiver's element, byte, or Unicode scalar count.

decode

decode() -> Res[Str, DataError]

Decodes UTF-8 bytes or returns DataError for malformed input.

get

get(f64) -> Opt[u8]

Returns Some(value) for a valid index and None otherwise.

Examples

Keep bytes distinct from text

Encoding is explicit; byte length and Unicode scalar count differ.

Tick 0 · 0.00 s⌘ / Ctrl + EnterThis device
main.kj
Loading the language runtime…
Output 0
No output.
Expected output
4
5
café

Rust definition

Value::Bin(konjure_sdk::data::Bin); shared immutable byte storage.

See also