std::pkg

Voyd API documentation generated from source declarations.

Table of Contents

mod std::array

Growable contiguous arrays with copy-on-write storage.
Supports negative indexing, range slicing, and eager sequence transforms.

Functions

fn new_array<T>({ from source: FixedArray<T> }) -> Optional<Array<T>>

Creates an array from fixed storage, returning None when null entries are present.

fn new_array_unchecked<T>({ from source: FixedArray<T> }) -> Array<T>

Creates an array from fixed storage without null-entry checks.

Objects

obj Array<T>

A growable contiguous collection with copy-on-write semantics.

impl<T> Array<T>

Members
init() -> Array<T>

Creates an empty array.

with_capacity(size: i32) -> Array<T>

Creates an empty array with capacity for at least size elements.

from(source: FixedArray<T>) -> Optional<Array<T>>

Builds a value from the provided source.

copied(self: Array<T>, add_capacity?: i32) -> Array<T>

Returns a shallow copy of the array.

When add_capacity is provided, the copy is guaranteed to have room for
at least that many additional items without reallocation.

Example:
let copy = values.copied(add_capacity: 8)

len(self: Array<T>) -> i32

Returns the number of stored elements.

capacity(self: Array<T>) -> i32

Returns how many elements can be stored before reallocation is required.

is_empty(self: Array<T>) -> bool

Returns true when no values are stored.

first(self: Array<T>) -> Optional<T>

Returns the first element, or None when empty.

last(self: Array<T>) -> Optional<T>

Returns the last element, or None when empty.

get(self: Array<T>, index: i32) -> Optional<T>

Returns the element at index, or None when out of bounds.

at(self: Array<T>, index: i32) -> T

Returns the value at the requested index and traps when the index is out of bounds.

slice(self: Array<T>, range: Range) -> Array<T>

Returns a subrange copy for the requested range.

Example:
let first_two = values.slice(0..2)

slice(self: Array<T>, { range: Range }) -> Array<T>

Returns a subrange copy for the requested range.

slice( self: Array<T>, { from start: i32 to end: i32 } ) -> Array<T>

Returns a subrange copy bounded by explicit indices.

Parameters:

  • start: Inclusive start index. Negative values index from the end.
  • end: Exclusive end index. Negative values index from the end.

Example:
let middle = values.slice(from: 1, to: -1)

map<O>( self: Array<T>, f: (v: T) -> O ) -> Array<O>

Applies a transform to each element and returns a new array.

filter( self: Array<T>, pred: (v: T) -> bool ) -> Array<T>

Returns a collection containing only values that satisfy the predicate.

filter( self: Array<T>, { where pred: (value: T) -> bool } ) -> Array<T>

Returns a collection containing only values that satisfy the predicate.

each( self: Array<T>, { do f: (value: T) -> void } ) -> void

Invokes a callback for each element.

flat_map<O>( self: Array<T>, f: (v: T) -> Array<O> ) -> Array<O>

Maps each element and flattens the mapped sequences into one array.

flat_map<O>( self: Array<T>, { map f: (value: T) -> Sequence<O> } ) -> Array<O>

Maps each element and flattens the mapped sequences into one array.

reduce<O>( self: Array<T>, initial: O, { step: (acc: O, v: T) -> O } ) -> O

Reduces values to a single accumulator value.

reduce<O>( self: Array<T>, { initial: O combine: (acc: O, value: T) -> O } ) -> O

Reduces values to a single accumulator value.

find( self: Array<T>, pred: (v: T) -> bool ) -> Optional<T>

Returns the first value that satisfies the predicate.

find( self: Array<T>, { where pred: (value: T) -> bool } ) -> Option<T>

Returns the first value that satisfies the predicate.

any( self: Array<T>, pred: (v: T) -> bool ) -> bool

Returns true when at least one element matches the predicate.

any( self: Array<T>, { where pred: (value: T) -> bool } ) -> bool

Returns true when at least one element matches the predicate.

all( self: Array<T>, pred: (v: T) -> bool ) -> bool

Returns true only when every element matches the predicate.

all( self: Array<T>, { where pred: (value: T) -> bool } ) -> bool

Returns true only when every element matches the predicate.

contains(self: Array<T>, value: T) -> bool

Returns true when a matching value exists.

contains( self: Array<T>, { where pred: (value: T) -> bool } ) -> bool

Returns true when a matching value exists.

find_index(self: Array<T>, value: T) -> i32

Returns the index of the first matching value.

find_index( self: Array<T>, { where pred: (value: T) -> bool } ) -> Option<i32>

Returns the index of the first matching value.

find_index_where( self: Array<T>, pred: (v: T) -> bool ) -> i32

Returns the index of the first value that satisfies the predicate, or -1 when absent.

sorted( self: Array<T>, compare: (left: T, right: T) -> i32 ) -> Array<T>

Returns a sorted copy.

sorted(self: Array<T>) -> Array<T>

Returns a sorted copy.

sorted( self: Array<T>, { by compare: (left: T, right: T) -> Ordering } ) -> Array<T>

Returns a sorted copy.

reversed(self: Array<T>) -> Array<T>

Returns a reversed copy.

to_fixed_array(self: Array<T>) -> FixedArray<T>

Copies values into a fixed-size array.

raw_storage(self: Array<T>) -> FixedArray<T>

Returns the underlying backing storage array.

enumerate(self: Array<T>) -> Array<(i32, T)>

Returns pairs of (index, value) for each element.

concat(self: Array<T>, other: Array<T>) -> Array<T>

Returns a new collection with other appended.

take(self: Array<T>, n: i32) -> Array<T>

Returns a new array containing the first n elements.

drop(self: Array<T>, n: i32) -> Array<T>

Returns a new array without the first n elements.

partition( self: Array<T>, pred: (v: T) -> bool ) -> (Array<T>, Array<T>)

Splits values into two arrays based on the predicate result.

partition( self: Array<T>, { where pred: (value: T) -> bool } ) -> (Array<T>, Array<T>)

Splits values into two arrays based on the predicate result.

chunk(self: Array<T>, { of size: i32 }) -> Array<Array<T>>

Splits values into consecutive chunks of the requested size.

Parameter:

  • size: Number of elements per chunk. Non-positive values return an empty array.
window(self: Array<T>, size: i32) -> Array<Array<T>>

Returns all sliding windows of the requested size.

Parameter:

  • size: Number of values per window. Must be between 1 and len.
zip<U>(self: Array<T>, other: Array<U>) -> Array<(T, U)>

Pairs values from two sequences until either sequence ends.

zip<U>(self: Array<T>, { other: Sequence<U> }) -> Array<(T, U)>

Pairs values from two sequences until either sequence ends.

fold( self: Array<T>, combine: (left: T, right: T) -> T ) -> Optional<T>

Combines all values into one using a binary reducer.

sort( ~self: Array<T>, compare: (left: T, right: T) -> i32 ) -> void

Sorts values in place.

sort(~self: Array<T>) -> void

Sorts values in place.

sort( ~self: Array<T>, { by compare: (left: T, right: T) -> Ordering } ) -> void

Sorts values in place.

reverse(~self: Array<T>) -> void

Reverses values in place.

clear(~self: Array<T>) -> void

Removes all stored values.

truncate(~self: Array<T>, len: i32) -> void

Shrinks the array to the requested length.

reserve(~self: Array<T>, additional: i32) -> void

Ensures capacity for at least additional more elements.

push(~self: Array<T>, value: T) -> void

Appends a value to the end.

pop(~self: Array<T>) -> Optional<T>

Removes and returns the last value.

insert(~self: Array<T>, value: T, { at index: i32 }) -> void

Inserts a value at the target location.

remove(~self: Array<T>, index: i32) -> Optional<T>

Removes and returns a value when present.

remove(~self: Array<T>, { at index: i32 }) -> T

Removes and returns a value when present.

extend(~self: Array<T>, other: Array<T>) -> void

Appends values from another collection or sequence.

extend(~self: Array<T>, { items: Sequence<T> }) -> void

Appends values from another collection or sequence.

splice( ~self: Array<T>, { at start: i32 removing remove_count: i32 inserting items: Array<T> } ) -> Array<T>

Replaces a range with inserted values and returns removed values.

Parameters:

  • start: Index where the splice begins. Clamped into 0..len.
  • remove_count: Number of existing values to remove.
  • items: Values inserted at start.

Example:
let removed = items.splice(at: 2, removing: 1, inserting: replacements)

replace(~self: Array<T>, index: i32, { with element: T }) -> bool

Replaces matching content with new content.

cleared(self: Array<T>) -> Array<T>

Returns a copy with all values removed.

reserved(self: Array<T>, additional: i32) -> Array<T>

Returns a copy with reserved additional capacity.

pushed(self: Array<T>, value: T) -> Array<T>

Returns a copy with one value appended.

popped(self: Array<T>) -> ArrayPop<T>

Returns a copy with the last value removed.

inserted(self: Array<T>, value: T, { at index: i32 }) -> Array<T>

Returns a copy with a value inserted at the requested index.

removed(self: Array<T>, index: i32) -> Array<T>

Returns a copy with one value removed.

extended(self: Array<T>, other: Array<T>) -> Array<T>

Returns a copy with values from other appended.

spliced( self: Array<T>, { at start: i32 removing remove_count: i32 inserting items: Array<T> } ) -> Array<T>

Returns a copy with a splice operation applied.

impl<T> Array<T> for Sequence<T>

Members
iter(self: Array<T>) -> Iterator<T>

Returns an iterator over values.

impl<T> Array<T> for SubscriptRead<i32, Optional<T>>

Members
subscript_get(self: Array<T>, index: i32) -> Optional<T>

Returns the value addressed by subscript syntax.

impl<T> Array<T> for SubscriptRead<Range, Array<T>>

Members
subscript_get(self: Array<T>, range: Range) -> Array<T>

Returns the value addressed by subscript syntax.

impl<T> Array<T> for SubscriptWrite<i32, T>

Members
subscript_set(~self: Array<T>, index: i32, value: T) -> void

Updates the value addressed by subscript syntax.

obj ArrayPop<T>

Result payload returned by Array::popped.

mod std::box

Objects

obj Box<T>

Generic single-value container.

Members
value: T

Contained boxed value.

mod std::bytes

Byte-oriented collection types.

Bytes is an immutable view over byte data and ByteBuffer is a mutable,
growable builder. These types are useful for protocol work, file formats,
and interop with UTF-8 string APIs.

Example:
String::from_utf8(buffer.as_bytes().to_array())
converts buffered bytes into a validated String.

Type Aliases

type Byte = i32

A single byte value in the range 0..255.

Objects

obj Bytes

An immutable byte sequence view.

impl Bytes

Members
len(self: Bytes) -> i32

Returns the number of bytes.

is_empty(self: Bytes) -> bool

Returns true when this sequence is empty.

get(self: Bytes, index: i32) -> Option<Byte>

Returns the byte at index, or None when out of bounds.

at(self: Bytes, index: i32) -> Byte

Returns the byte at index, trapping when out of bounds.

slice(self: Bytes, range: Range) -> Bytes

Returns a byte slice for the provided range.

  • range: half-open or closed range, following Range semantics.
slice(self: Bytes, { range: Range }) -> Bytes

Returns a byte slice for the provided range.

to_array(self: Bytes) -> Array<Byte>

Returns a copied array of bytes.

obj ByteBuffer

A mutable, growable byte buffer.

impl ByteBuffer

Members
init() -> ByteBuffer

Creates an empty byte buffer.

with_capacity(bytes: i32) -> ByteBuffer

Creates an empty byte buffer with at least bytes capacity.

Negative values are clamped to 0.

len(self: ByteBuffer) -> i32

Returns the number of bytes in the buffer.

is_empty(self: ByteBuffer) -> bool

Returns true when this buffer is empty.

capacity(self: ByteBuffer) -> i32

Returns total byte capacity.

as_bytes(self: ByteBuffer) -> Bytes

Returns an immutable bytes snapshot.

The returned Bytes is a copy of the current buffer contents.

push(~self: ByteBuffer, value: Byte) -> void

Appends one byte.

extend(~self: ByteBuffer, bytes: Bytes) -> void

Appends all bytes from bytes.

This is useful for concatenating previously captured Bytes values.

clear(~self: ByteBuffer) -> void

Removes all bytes.

mod std::deque

Double-ended queue built on top of std::array::Array.
Front operations are convenient but shift storage, so they are not constant-time.

Objects

obj Deque<T>

A double-ended queue.

Example:
let ~queue = Deque<i32>::init()
queue.push_back(1)
queue.push_front(0)

impl<T> Deque<T>

Members
init() -> Deque<T>

Creates an empty deque.

len(self: Deque<T>) -> i32

Returns the number of values.

is_empty(self: Deque<T>) -> bool

Returns true when the deque is empty.

push_front(~self: Deque<T>, value: T) -> void

Pushes value to the front.

push_back(~self: Deque<T>, value: T) -> void

Pushes value to the back.

pop_front(~self: Deque<T>) -> Option<T>

Pops and returns the front value.

pop_back(~self: Deque<T>) -> Option<T>

Pops and returns the back value.

front(self: Deque<T>) -> Option<T>

Returns the front value without removing it.

back(self: Deque<T>) -> Option<T>

Returns the back value without removing it.

clear(~self: Deque<T>) -> void

Removes all values.

mod std::dict

Hash-map style dictionary collection.

Provides key/value storage with entry APIs, merge helpers, and iteration utilities.
Keys must implement DictKey<K> to supply hash and equality behavior.

Objects

obj DictEntry<K, V>

Entry handle for conditional dictionary updates.

Use this value with or_insert, or_insert_with, and and_modify.

Members
dict: Dict<K, V>

Dictionary being accessed by this entry handle.

key: K

Associated key for this entry.

impl<K, V> DictEntry<K, V>

Members
or_insert(self: DictEntry<K, V>, default: V) -> Dict<K, V>

Inserts the default value when the entry is vacant and returns the dictionary.

or_insert_with( self: DictEntry<K, V>, make: (()) -> V ) -> Dict<K, V>

Lazily inserts a computed value when the entry is vacant and returns the dictionary.

and_modify( self: DictEntry<K, V>, f: (value: V) -> V ) -> DictEntry<K, V>

Applies a modifier function to the value when the entry already exists.

remove(self: DictEntry<K, V>) -> Optional<V>

Removes and returns a value when present.

obj Dict<K, V>

Mutable dictionary with hash-bucket storage.

Stores values by key and preserves only one value per key.

impl<K, V> Dict<K, V>

Members
init() -> Dict<K, V>

Creates an empty dictionary.

with_capacity(capacity: i32) -> Dict<K, V>

Creates an empty dictionary sized for an expected entry count.

Capacity is clamped to safe bounds and rounded up for bucket growth behavior.

len(self: Dict<K, V>) -> i32

Returns the number of stored elements.

is_empty(self: Dict<K, V>) -> bool

Returns true when no values are stored.

contains(self: Dict<K, V>, key: K) -> bool

Returns true when the dictionary currently stores key.

get(self: Dict<K, V>, key: K) -> Optional<V>

Returns the value for key, or None when absent.

insert(~self: Dict<K, V>, key: K, value: V) -> Optional<V>

Inserts a value at the target location.

set(~self: Dict<K, V>, key: K, value: V) -> void

Inserts or replaces the value for a key.

remove(~self: Dict<K, V>, key: K) -> Optional<V>

Removes and returns a value when present.

clear(~self: Dict<K, V>) -> void

Removes all stored values.

keys(self: Dict<K, V>) -> Array<K>

Returns all dictionary keys.

values(self: Dict<K, V>) -> Array<V>

Returns dictionary values.

entries(self: Dict<K, V>) -> Array<(K, V)>

Returns dictionary entries as key-value tuples.

each( self: Dict<K, V>, f: (key: K, value: V) -> void ) -> void

Invokes a callback for each element.

extend(~self: Dict<K, V>, other: Dict<K, V>) -> void

Appends values from another collection or sequence.

extend(~self: Dict<K, V>, { entries: Sequence<(K, V)> }) -> void

Appends values from another collection or sequence.

merged(self: Dict<K, V>, other: Dict<K, V>) -> Dict<K, V>

Returns a new dictionary containing entries from both inputs.

merged( self: Dict<K, V>, other: Dict<K, V>, resolve: (key: K, left: V, right: V) -> V ) -> Dict<K, V>

Returns a new dictionary containing entries from both inputs.

If a key appears in both dictionaries, resolve chooses the output value.

merge(~self: Dict<K, V>, other: Dict<K, V>) -> void

Merges entries from another dictionary into this dictionary.

merge( ~self: Dict<K, V>, other: Dict<K, V>, resolve: (key: K, left: V, right: V) -> V ) -> void

Merges entries from another dictionary into this dictionary.

map<U>( self: Dict<K, V>, f: (key: K, value: V) -> U ) -> Dict<K, U>

Transforms each value and keeps the original keys.

filter( self: Dict<K, V>, pred: (key: K, value: V) -> bool ) -> Dict<K, V>

Returns a collection containing only values that satisfy the predicate.

entry(self: Dict<K, V>, key: K) -> DictEntry<K, V>

Returns an entry handle for in-place updates on a specific key.

impl<K, V> Dict<K, V> for SubscriptRead<K, Optional<V>>

Members
subscript_get(self: Dict<K, V>, key: K) -> Optional<V>

Returns the value addressed by subscript syntax.

impl<K, V> Dict<K, V> for SubscriptWrite<K, V>

Members
subscript_set(~self: Dict<K, V>, key: K, value: V) -> void

Updates the value addressed by subscript syntax.

Traits

trait DictKey<K>

Key behavior required by Dict<K, V>.

Implementors define stable hashing and equality for dictionary lookups.

Members
dict_hash(self: <inferred>) -> i32

Returns a hash used to choose the key bucket.

dict_eq(self: <inferred>, other: K) -> bool

Returns true when this key equals other.

Implementations

impl<T> Array<T>

Members
group_by<K>( self: Array<T>, f: (value: T) -> K ) -> Dict<K, Array<T>>

Groups sequence values by key and returns grouped arrays.

impl String for DictKey<String>

Members
dict_hash(self: String) -> i32

Returns the hash code used for dictionary key bucketing.

dict_eq(self: String, other: String) -> bool

Compares this key with another key for dictionary equality.

mod std::encoding

Text/binary encoding helpers and shared decode error types.

Re-Exports

pub ascii

pub errors

pub hex

pub base64

pub errors::DecodeError

mod std::encoding::ascii

ASCII normalization helpers for byte-to-string conversions.

Functions

fn ascii_string_from(bytes: Array<i32>) -> String

Builds a safe string from ASCII byte values.

Params:

  • bytes: Byte values expected to be ASCII.

Any byte outside the 0-127 range is replaced with ? (63).

fn ascii_string_from_bytes(bytes: Array<i32>) -> String

Compatibility alias for ascii_string_from(bytes: ...).

mod std::encoding::base64

RFC 4648 base64 encode/decode helpers.

Functions

fn encode(bytes: Bytes) -> String

Encodes bytes as RFC 4648 base64 (with = padding).

Params:

  • bytes: Raw bytes to encode.

Returns an ASCII base64 string.

Example:

use std::encoding::base64
use std::bytes::ByteBuffer

let source = ByteBuffer::from_utf8("voyd")
let encoded = base64::encode(source.as_bytes())

fn decode(s: String) -> Result<Bytes, DecodeError>

Decodes a base64 string into bytes.

fn decode(s: StringSlice) -> Result<Bytes, DecodeError>

Decodes a base64 string into bytes.

Params:

  • s: Base64 text with optional = padding.

Returns:

  • Ok<Bytes> for valid base64 input.
  • Err<DecodeError> for invalid length, invalid characters, or invalid padding.

Example:

use std::encoding::base64

let decoded = base64::decode("dm95ZA==".as_slice())

mod std::encoding::errors

Re-Exports

pub std::error::DecodeError

mod std::encoding::hex

Lower-case hexadecimal encode/decode helpers.

Functions

fn encode(bytes: Bytes) -> String

Encodes bytes as lower-case hexadecimal.

Params:

  • bytes: Raw bytes to encode.

Returns an ASCII hex string that is always lower-case.

Example:

use std::encoding::hex
use std::bytes::ByteBuffer

let source = ByteBuffer::from_utf8("ok")
let encoded = hex::encode(source.as_bytes())

fn decode(s: String) -> Result<Bytes, DecodeError>

Decodes a hexadecimal string into bytes.

fn decode(s: StringSlice) -> Result<Bytes, DecodeError>

Decodes a hexadecimal string into bytes.

Params:

  • s: Hex text using two digits per byte.

Returns:

  • Ok<Bytes> for valid hex input.
  • Err<DecodeError> when the length is odd or any character is not hex.

Example:

use std::encoding::hex

let decoded = hex::decode("766f7964".as_slice())

mod std::enums

Macros

macro enum

Quick way to define a union type with multiple inline object variants.
For example:

enum Result
  Foo<T> { value: T }
  Bar { value: i32 }
  Baz

mod std::env

Environment variable access backed by host process APIs.

std::env exposes typed reads for string/boolean/integer values plus a host-backed
mutation API for setting variables.

Functions

fn get(key: String): Env -> Option<String>

Reads an environment variable as a string, returning None when the key is missing.

fn get(key: StringSlice): Env -> Option<String>

fn get_boolean(key: String): Env -> Option<bool>

Reads an environment variable and parses it as a boolean.

fn get_boolean(key: StringSlice): Env -> Option<bool>

fn get_bool(key: String): Env -> Option<bool>

Compatibility alias for get_boolean.

fn get_bool(key: StringSlice): Env -> Option<bool>

Compatibility alias for get_boolean.

fn get_integer(key: String): Env -> Option<i32>

Reads an environment variable and parses it as a 32-bit integer.

fn get_integer(key: StringSlice): Env -> Option<i32>

fn get_int(key: String): Env -> Option<i32>

Compatibility alias for get_integer.

fn get_int(key: StringSlice): Env -> Option<i32>

Compatibility alias for get_integer.

fn set(key: String, value: String): Env -> Result<Unit, HostError>

Sets an environment variable to the provided string value.

fn set(key: StringSlice, value: StringSlice): Env -> Result<Unit, HostError>

Effects

eff Env

Host environment effect used by std::env.

Operations in this effect mirror host process environment APIs and exchange
MessagePack payloads for typed decoding in this module.

Members
get(tail, key: MsgPack) -> MsgPack

Reads an environment variable value.

key is a MessagePack string.
Returns a MessagePack string when present, otherwise null.

set(tail, payload: MsgPack) -> MsgPack

Sets an environment variable.

payload contains { key, value }.
Returns { ok: true } on success or { ok: false, code, message } on failure.

mod std::error

Shared error object definitions and panic primitive for the standard library.

These types model common failure categories surfaced by std modules and host
effects, while panic exposes an intrinsic trap for unrecoverable failures.

Functions

fn panic(_message: String) -> void

Stops execution immediately with a panic.

fn panic(_message: StringSlice) -> void

Objects

obj Utf8Error

Members
message: String

Human-readable error message.

obj ParseIntError

Members
message: String

Human-readable error message.

obj ParseFloatError

Members
message: String

Human-readable error message.

obj DecodeError

Members
message: String

Human-readable error message.

obj JsonError

Members
message: String

Human-readable error message.

obj HostError

Members
code: i32

Machine-readable error code.

message: String

Human-readable error message.

obj IoError

Members
code: i32

Machine-readable error code.

message: String

Human-readable error message.

Traits

trait Error<T>

Members
message(self: <inferred>) -> String

mod std::fetch

HTTP request/response helpers backed by the host networking runtime.

std::fetch provides typed request and response DTOs plus convenience helpers
for common HTTP workflows. Requests are encoded as MessagePack maps for the host
Fetch effect and decoded back into Result<FetchResponse, HostError>.

Functions

fn header( { name: String value: String } ): () -> FetchHeader

Creates one header value.

fn header( { name: StringSlice value: StringSlice } ): () -> FetchHeader

Creates one header value.

fn request({ request: FetchRequest }): Fetch -> Result<FetchResponse, HostError>

Sends an HTTP request.

This is the lowest-level public API in this module and accepts a fully-built
FetchRequest value.

fn request( { method: String url: String headers?: FetchHeaders body?: String timeout_millis?: i32 } ): Fetch -> Result<FetchResponse, HostError>

Sends an HTTP request from explicit values.

Example:
let response = fetch::request_with(method: "PUT".as_slice(), url: url)

fn request( { method: StringSlice url: StringSlice headers?: FetchHeaders body?: StringSlice timeout_millis?: i32 } ): Fetch -> Result<FetchResponse, HostError>

Sends an HTTP request from explicit values.

Example:
let response = fetch::request_with(method: "PUT".as_slice(), url: url)

fn request_with( { method: String url: String headers?: FetchHeaders body?: String timeout_millis?: i32 } ): Fetch -> Result<FetchResponse, HostError>

Sends an HTTP request from explicit values.

fn request_with( { method: StringSlice url: StringSlice headers?: FetchHeaders body?: StringSlice timeout_millis?: i32 } ): Fetch -> Result<FetchResponse, HostError>

Sends an HTTP request from explicit values.

fn get(url: String): Fetch -> Result<FetchResponse, HostError>

Sends a GET request.

Example:
let response = fetch::request_get("https://voyd.dev".as_slice())

fn get(url: StringSlice): Fetch -> Result<FetchResponse, HostError>

Sends a GET request.

fn request_get(url: String): Fetch -> Result<FetchResponse, HostError>

Sends a GET request.

Example:
let response = fetch::request_get("https://voyd.dev".as_slice())

fn request_get(url: StringSlice): Fetch -> Result<FetchResponse, HostError>

Sends a GET request.

fn post( { url: String body: String } ): Fetch -> Result<FetchResponse, HostError>

Sends a POST request with a text body.

fn post( { url: StringSlice body: StringSlice } ): Fetch -> Result<FetchResponse, HostError>

Sends a POST request with a text body.

fn request_post( { url: String body: String } ): Fetch -> Result<FetchResponse, HostError>

Sends a POST request with a text body.

Example:
let response = fetch::request_post(url: api.as_slice(), body: payload.as_slice())

fn request_post( { url: StringSlice body: StringSlice } ): Fetch -> Result<FetchResponse, HostError>

Sends a POST request with a text body.

Type Aliases

type FetchHeaders = Array<FetchHeader>

Objects

obj FetchHeader

Members
name: String

Case-insensitive header field name.

value: String

Header value.

obj FetchRequest

Members
method: String

HTTP method (for example GET or POST).

url: String

Absolute request URL.

headers: FetchHeaders

Request headers.

body: String

Optional request body.

timeout_millis: i32

Optional timeout budget in milliseconds.

impl FetchRequest

Members
init( { method: String url: String headers?: FetchHeaders body?: String timeout_millis?: i32 } ) -> FetchRequest

Builds a request from explicit values.

init( { method: StringSlice url: StringSlice headers?: FetchHeaders body?: StringSlice timeout_millis?: i32 } ) -> FetchRequest

Builds a request from explicit values.

get(url: String) -> FetchRequest

Builds a GET request.

get(url: StringSlice) -> FetchRequest

Builds a GET request.

post( { url: String body: String } ) -> FetchRequest

Builds a POST request with a text body.

post( { url: StringSlice body: StringSlice } ) -> FetchRequest

Builds a POST request with a text body.

with_header( self: FetchRequest, { name: String value: String } ) -> FetchRequest

Returns a copy with one header appended.

with_header( self: FetchRequest, { name: StringSlice value: StringSlice } ) -> FetchRequest

Returns a copy with one header appended.

with_body(self: FetchRequest, body: String) -> FetchRequest

Returns a copy with a text body.

with_body(self: FetchRequest, body: StringSlice) -> FetchRequest

Returns a copy with a text body.

with_timeout(self: FetchRequest, millis: i32) -> FetchRequest

Returns a copy with a timeout budget in milliseconds.

send(self: FetchRequest): Fetch -> Result<FetchResponse, HostError>

Sends this request.

obj FetchResponse

Members
status: i32

HTTP response status code.

status_text: String

HTTP response status text.

headers: FetchHeaders

Response headers.

body: String

UTF-8 decoded response body text.

impl FetchResponse

Members
is_success(self: FetchResponse) -> bool

Returns true for 2xx status codes.

header(self: FetchResponse, name: String) -> Option<String>

Returns the first header value matching name.

header(self: FetchResponse, name: StringSlice) -> Option<String>

Returns the first header value matching name.

Effects

eff Fetch

Host networking effect used by std::fetch.

The payload is a MessagePack map with request metadata and optional body/timeout.

Members
request(tail, payload: MsgPack) -> MsgPack

Sends an HTTP request.

payload must encode:

  • method: HTTP method string (GET, POST, and so on)
  • url: absolute URL
  • headers: array of { name, value }
  • body: optional UTF-8 string or null
  • timeout_millis: optional i32 or null

Returns a MessagePack object shaped as:

  • success: { ok: true, value: <response dto> }
  • failure: { ok: false, code: i32, message: string }

mod std::fs

File system APIs backed by host runtime operations.

std::fs provides read/write/existence/listing helpers that operate on
std::path::Path and return typed Result values where host I/O can fail.
All effect payloads are MessagePack-encoded DTOs.

Functions

fn read_bytes(path: Path): Fs -> Result<Bytes, IoError>

Reads a file as raw bytes.

Example:
let bytes = fs::read_bytes(Path::new("./image.bin".as_slice()))

fn read(path: Path): Fs -> Result<String, IoError>

Reads text from a file.

This expects host-side UTF-8 text decoding.

fn read_string(path: Path): Fs -> Result<String, IoError>

Reads text from a file.

This expects host-side UTF-8 text decoding.

fn write_bytes(path: Path, bytes: Bytes): Fs -> Result<Unit, IoError>

Writes bytes to a file.

Example:
let write_result = fs::write_bytes(file_path, payload)

fn write(path: Path, value: String): Fs -> Result<Unit, IoError>

Writes text to a file.

Example:
let write_result = fs::write_string(file_path, "hello".as_slice())

fn write(path: Path, value: StringSlice): Fs -> Result<Unit, IoError>

Writes text to a file.

fn write_string(path: Path, value: String): Fs -> Result<Unit, IoError>

Writes text to a file.

Example:
let write_result = fs::write_string(file_path, "hello".as_slice())

fn write_string(path: Path, value: StringSlice): Fs -> Result<Unit, IoError>

Writes text to a file.

fn exists(path: Path): Fs -> bool

Returns true when the path exists in the file system.

fn list_dir(path: Path): Fs -> Result<Array<Path>, IoError>

Lists child paths in a directory.

Each returned Path is decoded from host-provided string entries.

Effects

eff Fs

Host file-system effect used by std::fs.

Operations in this effect proxy host file APIs using MessagePack payloads
and return DTOs decoded by helper functions in this module.

Members
read_bytes(tail, path: MsgPack) -> MsgPack

Reads file contents from path and returns raw byte data or an I/O error DTO.

read_string(tail, path: MsgPack) -> MsgPack

Reads UTF-8 text contents from path and returns string data or an I/O error DTO.

write_bytes(tail, payload: MsgPack) -> MsgPack

Writes raw byte data to a file.

payload contains { path, bytes }.

write_string(tail, payload: MsgPack) -> MsgPack

Writes UTF-8 text to a file.

payload contains { path, value }.

exists(tail, path: MsgPack) -> bool

Returns the host-reported existence check for path.

list_dir(tail, path: MsgPack) -> MsgPack

Lists child paths in the directory at path, or returns an I/O error DTO.

mod std::input

Standard input helpers backed by host-provided input streams.

std::input supports line-based reads, raw byte reads, and terminal detection.
Host interactions are encoded as MessagePack DTOs and decoded into typed results.

Functions

fn read_line(): Input -> Result<Option<String>, HostError>

Reads a line from stdin (or host prompt source).

Returns Ok(None) at end-of-input.

fn read_line(prompt: StringSlice): Input -> Result<Option<String>, HostError>

Reads a line using a prompt.

Example:
let next = input::read_line("> ".as_slice())

fn read_line(prompt: String): Input -> Result<Option<String>, HostError>

Reads a line using a prompt.

fn read_line(request: InputRequest): Input -> Result<Option<String>, HostError>

Reads a line using an explicit request value.

fn read_bytes(max_bytes: i32): Input -> Result<Option<Bytes>, IoError>

Reads up to max_bytes raw bytes from stdin.

Returns Ok(None) when no more bytes are available.

fn is_tty(): Input -> bool

Returns true when stdin is attached to an interactive terminal.

Objects

obj InputRequest

Members
prompt: String

Optional prompt shown before reading input.

impl InputRequest

Members
init(prompt?: StringSlice) -> InputRequest

Builds a read request.

init(prompt: String) -> InputRequest

Builds a read request.

Effects

eff Input

Host input effect used by std::input.

Operations in this effect map host stdin facilities into typed MessagePack
DTOs consumed by this module.

Members
read_line(tail, payload: MsgPack) -> MsgPack

Reads one line using the provided payload.

payload may include a prompt field (string or null).
Returns { ok, value } where value is a string or null, or an error DTO.

read_bytes_op(tail, payload: MsgPack) -> MsgPack

Reads up to max_bytes bytes from standard input.

payload contains { max_bytes }.
Returns { ok, value } where value is a byte array or null, or an error DTO.

is_tty_op(tail) -> bool

Reports whether stdin is attached to an interactive terminal.

mod std::json

JSON value model and UTF-8 parser/serializer helpers.
Use parse to decode JSON text into JsonValue and stringify/stringify_pretty
to encode values back to text.

Re-Exports

pub std::error::JsonError

Functions

fn parse(source: String) -> Result<JsonValue, JsonError>

Parses UTF-8 JSON text into a JsonValue.

Params:

  • source: JSON source text.

Returns:

  • Ok<JsonValue> when the full input parses successfully.
  • Err<JsonError> for malformed JSON or trailing characters.

Example:

use std::json

let parsed = json::parse("{\"ok\":true}")

fn parse(source: StringSlice) -> Result<JsonValue, JsonError>

fn stringify(value: JsonValue) -> String

Serializes a JsonValue to compact JSON text.

Params:

  • value: JSON value to serialize.

Example:

use std::json

let text = json::stringify(JsonBool { value: true })

fn stringify_pretty(value: JsonValue) -> String

Serializes a JsonValue to pretty JSON text with indentation.

Params:

  • value: JSON value to serialize.

Type Aliases

type JsonValue = |(JsonNull, |(JsonBool, |(JsonNumber, |(JsonString, |(JsonArray, JsonObject)))))

Tagged union over all supported JSON value variants.

Objects

obj JsonNull

Represents the JSON null literal.

obj JsonBool

Represents a JSON boolean literal.

Members
value: bool

Stored boolean payload.

obj JsonNumber

Represents a JSON number.

Members
value: f64

Stored numeric payload.

obj JsonString

Represents a JSON string.

Members
value: String

Stored string payload.

obj JsonArray

Represents a JSON array.

Members
value: Array<JsonValue>

Stored element values.

obj JsonObject

Represents a JSON object keyed by strings.

Members
value: Dict<String, JsonValue>

Stored object fields.

mod std::log

Structured logging primitives backed by a host logging sink.

std::log exposes level-specific helpers and typed field values for structured
payloads. Messages and fields are encoded as MessagePack maps/arrays.

Functions

fn trace(message: StringSlice): Log -> void

Emits a trace-level log message.

fn trace(message: String): Log -> void

Emits a trace-level log message.

fn trace(message: StringSlice, fields: LogFields): Log -> void

Emits a trace-level log message.

fn trace(message: String, fields: LogFields): Log -> void

Emits a trace-level log message.

fn debug(message: StringSlice): Log -> void

Emits a debug-level log message.

fn debug(message: String): Log -> void

Emits a debug-level log message.

fn debug(message: StringSlice, fields: LogFields): Log -> void

Emits a debug-level log message.

fn debug(message: String, fields: LogFields): Log -> void

Emits a debug-level log message.

fn info(message: StringSlice): Log -> void

Emits an info-level log message.

fn info(message: String): Log -> void

Emits an info-level log message.

fn info(message: StringSlice, fields: LogFields): Log -> void

Emits an info-level log message.

fn info(message: String, fields: LogFields): Log -> void

Emits an info-level log message.

fn warn(message: StringSlice): Log -> void

Emits a warning-level log message.

fn warn(message: String): Log -> void

Emits a warning-level log message.

fn warn(message: StringSlice, fields: LogFields): Log -> void

Emits a warning-level log message.

fn warn(message: String, fields: LogFields): Log -> void

Emits a warning-level log message.

fn error(message: StringSlice): Log -> void

Emits an error-level log message.

fn error(message: String): Log -> void

Emits an error-level log message.

fn error(message: StringSlice, fields: LogFields): Log -> void

Emits an error-level log message.

fn error(message: String, fields: LogFields): Log -> void

Emits an error-level log message.

Type Aliases

type LogLevel = |(LogTrace, |(LogDebug, |(LogInfo, |(LogWarn, LogError))))

type LogFieldValue = |(LogString, |(LogInt, |(LogFloat, LogBool)))

type LogFields = Array<LogField>

Objects

obj LogTrace

obj LogDebug

obj LogInfo

obj LogWarn

obj LogError

obj LogString

Members
value: String

String field payload.

obj LogInt

Members
value: i64

Integer field payload.

obj LogFloat

Members
value: f64

Floating-point field payload.

obj LogBool

Members
value: bool

Boolean field payload.

obj LogField

Members
key: String

Associated key for this entry.

value: LogFieldValue

Log field payload.

Effects

eff Log

Host logging effect used by std::log.

std::log converts typed log-level and field values into a MessagePack map
consumed by the host log sink.

Members
emit(tail, payload: MsgPack) -> void

Emits one structured log event.

payload is a map with:

  • level: one of trace|debug|info|warn|error
  • message: log message string
  • fields: array of { key, value } entries or null

mod std::math

Math APIs for integer, float, interpolation, constants, and math errors.
Import through std::math for namespaced calls (for example,
math::pow(2.0, 3.0)), or import math::all to enable UFCS-style calls
such as 2.0.pow(3.0).

Re-Exports

pub constants

pub errors

pub float

pub int

pub interpolate

pub errors::MathError

pub constants::all

pub float::all

pub int::all

pub interpolate::all

mod std::math::constants

Mathematical constants and unit conversion helpers.

Functions

fn pi_f64() -> f64

Returns Archimedes' constant as f64.

fn pi_f32() -> f32

Returns Archimedes' constant as f32.

fn tau_f64() -> f64

Returns Tau (2Ï€) as f64.

fn tau_f32() -> f32

Returns Tau (2Ï€) as f32.

fn e_f64() -> f64

Returns Euler's number as f64.

fn e_f32() -> f32

Returns Euler's number as f32.

fn deg_to_rad(value: f64) -> f64

Converts degrees to radians.
value is interpreted as degrees.

fn deg_to_rad(value: f32) -> f32

Converts degrees to radians.

fn rad_to_deg(value: f64) -> f64

Converts radians to degrees.
value is interpreted as radians.

fn rad_to_deg(value: f32) -> f32

Converts radians to degrees.

mod std::math::errors

Math-specific error types and stable error code helpers.

Functions

fn math_error_code_invalid_input() -> i32

Error code for invalid input values.

fn math_error_code_overflow() -> i32

Error code for overflow conditions.

fn math_error_code_divide_by_zero() -> i32

Error code for divide-by-zero conditions.

fn math_error<T>(code: i32) -> Result<T, MathError>

Constructs a MathError result with the provided code.

Objects

obj MathError

Error type returned by fallible std math APIs.

Members
code: i32

Machine-readable error code.

mod std::math::float

Floating-point and numeric helper APIs used by std::math.
Functions in this module favor direct Wasm intrinsics for predictable
runtime behavior across hosts.

Functions

fn abs(value: i32) -> Result<i32, MathError>

Returns the absolute value, rejecting signed overflow.

fn abs(value: i64) -> Result<i64, MathError>

Returns the absolute value, rejecting signed overflow.

fn abs(value: f64) -> f64

Returns the absolute value.

fn abs(value: f32) -> f32

Returns the absolute value.

fn signum(value: i32) -> i32

Returns the sign of value as -1, 0, or 1.

fn signum(value: i64) -> i64

Returns the sign of value as -1, 0, or 1.

fn signum(value: f64) -> f64

Returns the sign of value as -1, 0, or 1.
Returns NaN unchanged.

fn signum(value: f32) -> f32

Returns the sign of value as -1, 0, or 1.
Returns NaN unchanged.

fn floor(value: f64) -> f64

Rounds value down to the nearest integer.

fn floor(value: f32) -> f32

Rounds value down to the nearest integer.

fn ceil(value: f64) -> f64

Rounds value up to the nearest integer.

fn ceil(value: f32) -> f32

Rounds value up to the nearest integer.

fn round(value: f64) -> f64

Rounds value to the nearest integer using ties-to-even semantics.

fn round(value: f32) -> f32

Rounds value to the nearest integer using ties-to-even semantics.

fn trunc(value: f64) -> f64

Rounds value toward zero.

fn trunc(value: f32) -> f32

Rounds value toward zero.

fn fract(value: f64) -> f64

Returns the fractional component of value.

fn fract(value: f32) -> f32

Returns the fractional component of value.

fn sqrt(value: f64) -> f64

Returns the square root of value.

fn sqrt(value: f32) -> f32

Returns the square root of value.

fn hypot(x: f64, y: f64) -> f64

Returns the Euclidean norm of (x, y): sqrt(xx + yy).

fn hypot(x: f32, y: f32) -> f32

Returns the Euclidean norm of (x, y): sqrt(xx + yy).

fn pow(value: f64, exponent: f64) -> f64

Raises value to the power of exponent.

fn pow(value: f32, exponent: f32) -> f32

Raises value to the power of exponent.

fn sin(value: f64) -> f64

Returns the sine of value (radians).

fn sin(value: f32) -> f32

Returns the sine of value (radians).

fn cos(value: f64) -> f64

Returns the cosine of value (radians).

fn cos(value: f32) -> f32

Returns the cosine of value (radians).

fn tan(value: f64) -> f64

Returns the tangent of value (radians).

fn tan(value: f32) -> f32

Returns the tangent of value (radians).

fn atan2(y: f64, x: f64) -> f64

Returns the angle in radians between the positive x-axis and (x, y).
Parameter order follows atan2(y, x).

fn atan2(y: f32, x: f32) -> f32

Returns the angle in radians between the positive x-axis and (x, y).
Parameter order follows atan2(y, x).

fn ln(value: f64) -> f64

Returns the natural logarithm (base e).

fn ln(value: f32) -> f32

Returns the natural logarithm (base e).

fn log2(value: f64) -> f64

Returns the base-2 logarithm.

fn log2(value: f32) -> f32

Returns the base-2 logarithm.

fn log10(value: f64) -> f64

Returns the base-10 logarithm.

fn log10(value: f32) -> f32

Returns the base-10 logarithm.

fn exp(value: f64) -> f64

Returns e raised to value.

fn exp(value: f32) -> f32

Returns e raised to value.

fn is_nan(value: f64) -> bool

Returns true when value is NaN.

fn is_nan(value: f32) -> bool

Returns true when value is NaN.

fn is_finite(value: f64) -> bool

Returns true when value is finite.
Finite means not NaN and not positive/negative infinity.

fn is_finite(value: f32) -> bool

Returns true when value is finite.

fn is_infinite(value: f64) -> bool

Returns true when value is infinite.

fn is_infinite(value: f32) -> bool

Returns true when value is infinite.

mod std::math::int

Integer math helpers for comparisons, Euclidean remainder, and
overflow-aware arithmetic operations.

Functions

fn max<T>(a: T, b: T) -> T

Returns the larger of a and b.

fn min<T>(a: T, b: T) -> T

Returns the smaller of a and b.

fn mod_euclid(value: i32, modulus: i32) -> Result<i32, MathError>

Returns the non-negative Euclidean remainder for 32-bit integers.
modulus must be greater than zero.

fn mod_euclid(value: i64, modulus: i64) -> Result<i64, MathError>

Returns the non-negative Euclidean remainder for 64-bit integers.
modulus must be greater than zero.

fn rem_euclid(value: i32, modulus: i32) -> Result<i32, MathError>

Returns the Euclidean remainder for 32-bit integers.

fn rem_euclid(value: i64, modulus: i64) -> Result<i64, MathError>

Returns the Euclidean remainder for 64-bit integers.

fn div_rem(value: i32, divisor: i32) -> (i32, i32)

Returns quotient and remainder for 32-bit integers.
divisor must not be zero.

fn div_rem(value: i64, divisor: i64) -> (i64, i64)

Returns quotient and remainder for 64-bit integers.
divisor must not be zero.

fn checked_div_rem(value: i32, divisor: i32) -> Result<(i32, i32), MathError>

Returns quotient and remainder, rejecting divide-by-zero and signed overflow.
Signed overflow covers the MIN / -1 case.

fn checked_div_rem(value: i32, { by divisor: i32 }) -> Result<(i32, i32), MathError>

Returns quotient and remainder using a labeled divisor argument.

fn checked_div_rem(value: i64, divisor: i64) -> Result<(i64, i64), MathError>

Returns quotient and remainder, rejecting divide-by-zero and signed overflow.
Signed overflow covers the MIN / -1 case.

fn checked_div_rem(value: i64, { by divisor: i64 }) -> Result<(i64, i64), MathError>

Returns quotient and remainder using a labeled divisor argument.

fn next_power_of_two(value: i32) -> Result<i32, MathError>

Returns the next power of two for a 32-bit integer.
Values less than or equal to 1 return 1.

fn is_power_of_two(value: i32) -> bool

Returns true when value is a power of two.

fn is_power_of_two(value: i64) -> bool

Returns true when value is a power of two.

fn prev_power_of_two(value: i32) -> Result<i32, MathError>

Returns the greatest power of two less than or equal to value.
value must be positive.

fn prev_power_of_two(value: i64) -> Result<i64, MathError>

Returns the greatest power of two less than or equal to value.
value must be positive.

fn next_multiple_of(value: i32, factor: i32) -> Result<i32, MathError>

Returns the smallest multiple of factor that is greater than or equal to value.
factor must be positive.

fn next_multiple_of(value: i64, factor: i64) -> Result<i64, MathError>

Returns the smallest multiple of factor that is greater than or equal to value.
factor must be positive.

mod std::math::interpolate

Interpolation and range-mapping helpers for scalar numeric values.
Includes clamping, range checks, forward interpolation, inverse
interpolation, and range remapping.

Functions

fn clamp(value: i32, min: i32, max: i32) -> i32

Returns value clamped between min and max (inclusive).

fn clamp( value: i32, { min: i32 max: i32 } ) -> i32

Returns value clamped between min and max (inclusive).

fn clamp(value: i64, min: i64, max: i64) -> i64

Returns value clamped between min and max (inclusive).

fn clamp( value: i64, { min: i64 max: i64 } ) -> i64

Returns value clamped between min and max (inclusive).

fn clamp(value: f32, min: f32, max: f32) -> f32

Returns value clamped between min and max (inclusive).

fn clamp( value: f32, { min: f32 max: f32 } ) -> f32

Returns value clamped between min and max (inclusive).

fn clamp(value: f64, min: f64, max: f64) -> f64

Returns value clamped between min and max (inclusive).

fn clamp( value: f64, { min: f64 max: f64 } ) -> f64

Returns value clamped between min and max (inclusive).

fn between(value: i32, min: i32, max: i32) -> bool

Returns true when value is within min..=max.

fn between( value: i32, { min: i32 max: i32 } ) -> bool

Returns true when value is within min..=max.

fn between(value: i64, min: i64, max: i64) -> bool

Returns true when value is within min..=max.

fn between( value: i64, { min: i64 max: i64 } ) -> bool

Returns true when value is within min..=max.

fn between(value: f32, min: f32, max: f32) -> bool

Returns true when value is within min..=max.

fn between( value: f32, { min: f32 max: f32 } ) -> bool

Returns true when value is within min..=max.

fn between(value: f64, min: f64, max: f64) -> bool

Returns true when value is within min..=max.

fn between( value: f64, { min: f64 max: f64 } ) -> bool

Returns true when value is within min..=max.

fn lerp(start: f64, end: f64, t: f64) -> f64

Returns the linear interpolation between start and end at t.
t is interpolation progress where 0 returns start and 1 returns end.
Example: lerp(10.0, 20.0, 0.25) == 12.5.
Supports UFCS call style: 0.0.lerp(10.0, 0.25).

fn lerp( start: f64, { to end: f64 at t: f64 } ) -> f64

Returns the linear interpolation between start and end at t.

fn lerp(start: f32, end: f32, t: f32) -> f32

Returns the linear interpolation between start and end at t.
t is interpolation progress where 0 returns start and 1 returns end.

fn lerp( start: f32, { to end: f32 at t: f32 } ) -> f32

Returns the linear interpolation between start and end at t.

fn inverse_lerp(value: f64, start: f64, end: f64) -> f64

Returns interpolation progress of value within the range start..end.
A return value of 0 means value == start, and 1 means value == end.
Example: inverse_lerp(5.0, 0.0, 10.0) == 0.5.
Supports UFCS call style: 5.0.inverse_lerp(0.0, 10.0).

fn inverse_lerp( value: f64, { start: f64 end: f64 } ) -> f64

Returns interpolation progress of value within the range start..end.

fn inverse_lerp(value: f32, start: f32, end: f32) -> f32

Returns interpolation progress of value within the range start..end.
A return value of 0 means value == start, and 1 means value == end.

fn inverse_lerp( value: f32, { start: f32 end: f32 } ) -> f32

Returns interpolation progress of value within the range start..end.

fn map_range(value: f64, in_min: f64, in_max: f64, out_min: f64, out_max: f64) -> f64

Maps value from one range into another range.
in_min/in_max define the input range and out_min/out_max define
the destination range.
Example: map_range(5.0, 0.0, 10.0, 100.0, 200.0) == 150.0.
Supports UFCS call style: 5.0.map_range(0.0, 10.0, 100.0, 200.0).

fn map_range( value: f64, { in_min: f64 in_max: f64 out_min: f64 out_max: f64 } ) -> f64

Maps value from one range into another range.

fn map_range(value: f32, in_min: f32, in_max: f32, out_min: f32, out_max: f32) -> f32

Maps value from one range into another range.

fn map_range( value: f32, { in_min: f32 in_max: f32 out_min: f32 out_max: f32 } ) -> f32

Maps value from one range into another range.

mod std::memory

Low-level WebAssembly linear memory intrinsics.

These APIs are thin wrappers over compiler intrinsics and are intended for
runtime and systems-level utilities that need explicit memory access.

Functions

fn size(): () -> i32

Returns the current WebAssembly memory size in pages.

fn grow(pages: i32): () -> i32

Grows WebAssembly linear memory by page count and returns the previous size.

fn load_u8(ptr: i32): () -> i32

Reads an unsigned 8-bit value from linear memory.

fn store_u8(ptr: i32, value: i32): () -> void

Writes an unsigned 8-bit value to linear memory.

fn load_u16(ptr: i32): () -> i32

Reads an unsigned 16-bit value from linear memory.

fn store_u16(ptr: i32, value: i32): () -> void

Writes an unsigned 16-bit value to linear memory.

fn load_u32(ptr: i32): () -> i32

Reads an unsigned 32-bit value from linear memory.

fn store_u32(ptr: i32, value: i32): () -> void

Writes an unsigned 32-bit value to linear memory.

fn copy(dest: i32, src: i32, len: i32): () -> void

Copies len bytes from src to dest in linear memory.

mod std::msgpack

Public MessagePack API surface for constructing values and encoding/decoding
them at the Wasm memory boundary.

Re-Exports

pub fns::MsgPack

pub types::Binary

pub types::Bool

pub types::F64

pub types::Null

pub types::Numeric

Functions

fn make_null(): () -> MsgPack

Returns a MessagePack null value.

fn make_bool(value: bool): () -> MsgPack

Wraps a boolean as a MessagePack value.

fn make_string(value: String): () -> MsgPack

Wraps a string as a MessagePack value.

fn make_binary(value: Binary): () -> MsgPack

Wraps binary data as a MessagePack value.

fn make_array(value: Array<MsgPack>): () -> MsgPack

Wraps an array as a MessagePack value.

fn make_f32(value: f32): () -> MsgPack

Wraps a 32-bit float as a MessagePack value.

fn make_f64(value: f64): () -> MsgPack

Wraps a 64-bit float as a MessagePack value.

fn make_i32(value: i32): () -> MsgPack

Wraps a 32-bit integer as a MessagePack value.

fn make_i64(value: i64): () -> MsgPack

Wraps a 64-bit integer as a MessagePack value.

fn make_map(value: Dict<String, MsgPack>): () -> MsgPack

Wraps a string-keyed dictionary as a MessagePack map value.

fn unpack_bool(value: MsgPack): () -> bool

Extracts a boolean from a MessagePack value.

fn unpack_string(value: MsgPack): () -> String

Extracts a string from a MessagePack value.

fn unpack_binary(value: MsgPack): () -> Binary

Extracts binary data from a MessagePack value.

fn unpack_array(value: MsgPack): () -> Array<MsgPack>

Extracts an array from a MessagePack value.

fn unpack_f32(value: MsgPack): () -> f32

Extracts a 32-bit float from a MessagePack value.

fn unpack_f64(value: MsgPack): () -> f64

Extracts a 64-bit float from a MessagePack value.

fn unpack_i32(value: MsgPack): () -> i32

Extracts a 32-bit integer from a MessagePack value.

fn unpack_i64(value: MsgPack): () -> i64

Extracts a 64-bit integer from a MessagePack value.

fn unpack_map(value: MsgPack): () -> Dict<String, MsgPack>

Extracts a string-keyed map from a MessagePack value.

fn pack_null(): () -> MsgPack

Alias for creating a MessagePack null value.

fn pack_bool(value: bool): () -> MsgPack

Alias for creating a MessagePack boolean value.

fn pack_string(value: String): () -> MsgPack

Alias for creating a MessagePack string value.

fn pack_binary(value: Binary): () -> MsgPack

Alias for creating a MessagePack binary value.

fn pack_array(value: Array<MsgPack>): () -> MsgPack

Alias for creating a MessagePack array value.

fn pack_f32(value: f32): () -> MsgPack

Alias for creating a MessagePack 32-bit float value.

fn pack_f64(value: f64): () -> MsgPack

Alias for creating a MessagePack 64-bit float value.

fn pack_i32(value: i32): () -> MsgPack

Alias for creating a MessagePack 32-bit integer value.

fn pack_i64(value: i64): () -> MsgPack

Alias for creating a MessagePack 64-bit integer value.

fn pack_map(value: Dict<String, MsgPack>): () -> MsgPack

Alias for creating a MessagePack map value.

fn encode_value(value: MsgPack, ptr: i32, len: i32): () -> i32

Encodes one MessagePack value into a caller-provided memory region.

Params:

  • value: MessagePack value to encode.
  • ptr: Start offset in linear memory where bytes are written.
  • len: Maximum bytes available at ptr.

Returns the number of bytes written, or -1 if the destination region is too small.

Example:

use std::msgpack

let used = msgpack::encode_value(msgpack::make_i32(7), ptr, len)

fn decode_value(ptr: i32, len: i32): () -> MsgPack

Decodes one MessagePack value from a memory region.

Params:

  • ptr: Start offset in linear memory where encoded bytes are read.
  • len: Number of readable bytes from ptr.

Returns the decoded value, or Null when decoding fails.

Example:

use std::msgpack

let value = msgpack::decode_value(ptr, len)

mod std::msgpack::fns

MessagePack serializer implementation used by std::msgpack.
This module owns the in-memory codec and value constructors/unpackers.

Type Aliases

type MsgPack = |(Null, |(Numeric, |(Bool, |(String, |(Binary, |(Array<MsgPack>, MsgPackMap))))))

Recursive MessagePack value union used by the serializer boundary.

mod std::msgpack::types

Primitive wrapper types used by std::msgpack value unions.

Type Aliases

type Numeric = |(I32, |(I64, |(F32, F64)))

Numeric subset of MessagePack wrapper types.

Objects

obj F64

MessagePack 64-bit float wrapper.

Members
value: f64

Wrapped payload value.

obj Bool

MessagePack boolean wrapper.

Members
value: bool

Wrapped payload value.

obj Null

MessagePack null wrapper.

obj Binary

MessagePack binary payload wrapper.

Members
bytes: Array<i32>

Raw bytes stored by this value.

mod std::optional

Optional standard module.

Re-exports optional value types and helper functions.

Re-Exports

pub types::all

pub fns::all

Macros

macro ??

macro ?.

mod std::optional::fns

Optional helper functions.

Constructors, predicates, and combinators for Optional<T> values.

Macros

macro ??

macro ?.

Functions

fn some<T>(value: T): () -> Optional<T>

Constructs an optional value containing value.

Parameters
  • value

    Value to wrap in Some.

fn none<T>(): () -> Optional<T>

Constructs an empty optional value.

fn is_some<T>(opt: Optional<T>): () -> boolean

Returns true when the optional value is present.

Parameters
  • opt

    Optional value to inspect.

fn is_none<T>(opt: Optional<T>): () -> boolean

Returns true when the optional value is absent.

Parameters
  • opt

    Optional value to inspect.

fn unwrap_or<T>(opt: Optional<T>, default: T): () -> T

Returns the contained value or a fallback.

Parameters
  • opt

    Optional value to unwrap.

  • default

    Fallback value returned for None.

fn unwrap_or_else<T>( opt: Optional<T>, default: (()) -> T ) -> T

Returns the contained value or computes a fallback lazily.

Parameters
  • opt

    Optional value to unwrap.

  • default

    Function invoked only when opt is None.

fn map<T, U>( opt: Optional<T>, f: (v: T) -> U ) -> Optional<U>

Transforms a present value and leaves None unchanged.

Parameters
  • opt

    Optional value to transform.

  • f

    Mapping function applied to Some payloads.

fn and_then<T, U>( opt: Optional<T>, f: (v: T) -> Optional<U> ) -> Optional<U>

Runs f when a value is present and flattens the result.

Parameters
  • opt

    Optional value to transform.

  • f

    Function applied to Some payloads.

fn or_value<T>(opt: Optional<T>, fallback: Optional<T>): () -> Optional<T>

Returns opt when present, otherwise fallback.

Parameters
  • opt

    Primary optional value.

  • fallback

    Fallback optional value used for None.

fn or_else<T>( opt: Optional<T>, fallback: (()) -> Optional<T> ) -> Optional<T>

Returns opt when present, otherwise computes a fallback optional value.

Parameters
  • opt

    Primary optional value.

  • fallback

    Function invoked to compute a fallback for None.

mod std::optional::types

Optional type definitions.

Defines Some, None, and aliases used across the standard library.

Type Aliases

type Optional<T> = |(Some<T>, None)

Optional sum type.

Represents either Some<T> or None.

type Option<T> = Optional<T>

Alias for Optional<T>.

Objects

obj Some<T>

Present optional variant.

Contains a payload value of type T.

Members
value: T

Stored payload value.

obj None

Empty optional variant.

mod std::output

Standard output/error stream helpers backed by host runtime operations.

std::output provides text and byte writes, flushing, and TTY checks for
stdout and stderr using MessagePack DTO payloads.

Functions

fn write(value: StringSlice): Output -> Result<Unit, IoError>

Writes text to the selected output target (stdout by default).

Example:
let result = output::write("hello".as_slice())

fn write(value: String): Output -> Result<Unit, IoError>

Writes text to the selected output target (stdout by default).

fn write(value: StringSlice, target: OutputTarget): Output -> Result<Unit, IoError>

Writes text to the selected output target.

fn write(value: String, target: OutputTarget): Output -> Result<Unit, IoError>

Writes text to the selected output target.

fn write_line(value: StringSlice): Output -> Result<Unit, IoError>

Writes text followed by exactly \n to the selected target (stdout by default).

fn write_line(value: String): Output -> Result<Unit, IoError>

Writes text followed by exactly \n to the selected target (stdout by default).

fn write_line(value: StringSlice, target: OutputTarget): Output -> Result<Unit, IoError>

Writes text followed by exactly \n to the selected target.

This always appends a single line-feed byte (0x0A).

fn write_line(value: String, target: OutputTarget): Output -> Result<Unit, IoError>

Writes text followed by exactly \n to the selected target.

fn write(bytes: Bytes): Output -> Result<Unit, IoError>

Writes bytes to the selected output target (stdout by default).

Use this when you need binary output instead of UTF-8 text.

fn write(bytes: Bytes, target: OutputTarget): Output -> Result<Unit, IoError>

Writes bytes to the selected output target.

fn write_bytes(bytes: Bytes): Output -> Result<Unit, IoError>

Writes bytes to the selected output target (stdout by default).

Use this when you need binary output instead of UTF-8 text.

fn write_bytes(bytes: Bytes, target: OutputTarget): Output -> Result<Unit, IoError>

Writes bytes to the selected output target.

fn flush(): Output -> Result<Unit, IoError>

Flushes the selected output target (stdout by default).

fn flush(target: OutputTarget): Output -> Result<Unit, IoError>

Flushes the selected output target.

fn is_tty(): Output -> bool

Returns true when the selected output target is a terminal (stdout by default).

fn is_tty(target: OutputTarget): Output -> bool

Returns true when the selected output target is a terminal.

Type Aliases

type OutputTarget = |(StdOut, StdErr)

Objects

obj StdOut

obj StdErr

Effects

eff Output

Host output effect used by std::output.

Operations in this effect forward writes/flushes to host-managed stdout and
stderr streams using MessagePack DTO payloads.

Members
write_op(tail, payload: MsgPack) -> MsgPack

Writes UTF-8 text to the selected output stream.

payload contains { value, target }, where target is "stdout" or "stderr".

write_bytes_op(tail, payload: MsgPack) -> MsgPack

Writes raw bytes to the selected output stream.

payload contains { bytes, target }.

flush_op(tail, payload: MsgPack) -> MsgPack

Flushes buffered data for the selected output stream.

payload contains { target }.

is_tty_op(tail, payload: MsgPack) -> bool

Returns whether the selected stream is a terminal.

payload contains { target }.

mod std::path

Pure path string utilities.

std::path performs lexical path composition and inspection without touching
the file system. Use std::fs when you need host-backed path existence or I/O.

Objects

obj Path

impl Path

Members
new(path: String) -> Path

Constructs a value from the provided input.

new(path: StringSlice) -> Path

Constructs a value from the provided input.

as_string(self: Path) -> String

Returns the path as a string value.

join(self: Path, child: String) -> Path

Returns a path with child appended.

join(self: Path, child: StringSlice) -> Path

Returns a path with child appended.

parent(self: Path) -> Option<Path>

Returns the parent path when one exists.

file_name(self: Path) -> Option<String>

Returns the final path segment when one exists.

mod std::pkg

Standard library package root exports.

This module re-exports core std modules and common types/functions for convenient
import via std::pkg.

Re-Exports

pub array

pub optional

pub result

pub prelude

pub error

pub version

pub enums

pub string

pub box

pub memory

pub msgpack

pub dict

pub subscript

pub traits

pub bytes

pub encoding

pub json

pub set

pub deque

pub error

pub log

pub time

pub random

pub env

pub fetch

pub input

pub output

pub path

pub fs

pub test

pub std::optional::types::Optional

pub std::optional::types::Option

pub std::optional::types::Some

pub std::optional::types::None

pub std::optional::fns::all

pub std::result::types::Result

pub std::result::types::Ok

pub std::result::types::Err

pub std::result::fns::all

pub std::enums::enum

pub std::array::Array

pub std::array::ArrayPop

pub std::array::new_array_unchecked

pub std::dict::Dict

pub std::dict::DictEntry

pub std::dict::DictKey

pub std::traits::Sequence

pub std::traits::Iterator

pub std::traits::for

pub std::subscript::Range

pub std::subscript::SubscriptRead

pub std::subscript::SubscriptWrite

pub std::bytes::Byte

pub std::bytes::Bytes

pub std::bytes::ByteBuffer

pub std::encoding::errors::DecodeError

pub std::string::String

pub std::string::StringSlice

pub std::string::StringIndex

pub std::string::CharSet

pub std::string::Utf8Error

pub std::string::ParseIntError

pub std::string::ParseFloatError

pub std::string::new_string

pub std::string::from_utf8

pub std::box::Box

pub std::json::JsonArray

pub std::json::JsonBool

pub std::json::JsonError

pub std::json::JsonNull

pub std::json::JsonNumber

pub std::json::JsonObject

pub std::json::JsonString

pub std::json::JsonValue

pub std::json::parse

pub std::json::stringify

pub std::json::stringify_pretty

pub std::set::Set

pub std::deque::Deque

pub std::traits::all

pub std::test::assertions::Test

pub std::test::assertions::assert

pub vx

pub math

Macros

macro ??

macro ?.

macro enum

macro for

mod std::prelude

Re-Exports

pub std::optional::types::Optional

pub std::optional::types::Option

pub std::optional::types::Some

pub std::optional::types::None

pub std::optional::fns::some

pub std::optional::fns::none

pub std::result::types::Result

pub std::result::types::Ok

pub std::result::types::Err

pub std::result::fns::ok

pub std::result::fns::err

pub std::traits::Eq

pub std::traits::Ord

pub std::traits::Hash

pub std::traits::Default

pub std::traits::Clone

pub std::traits::Copy

pub std::traits::Sequence

pub std::traits::Iterator

pub std::subscript::Range

pub std::array::Array

pub std::array::ArrayPop

pub std::array::new_array

pub std::array::new_array_unchecked

pub std::dict::Dict

pub std::dict::DictEntry

pub std::dict::DictKey

pub std::deque::Deque

pub std::set::Set

pub std::bytes::Byte

pub std::bytes::Bytes

pub std::bytes::ByteBuffer

pub std::box::Box

pub std::math

pub std::string::String

pub std::string::StringSlice

pub std::string::StringIndex

pub std::string::CharSet

pub std::string::Utf8Error

pub std::string::ParseIntError

pub std::string::ParseFloatError

pub std::string::new_string

pub std::string::from_utf8

pub std::error::panic

pub std::test::assertions::assert

mod std::random

Random-number and random-byte helpers backed by the host Random effect.
The host implementation is expected to provide cryptographically secure
randomness when available.

Functions

fn next_i64(): Random -> i64

Returns a random 64-bit integer.

fn fill_bytes(~buf: ByteBuffer, len: i32): Random -> void

Fills a byte buffer with cryptographically secure random bytes.
len controls the number of bytes appended to buf.
Example:
let buf = ByteBuffer::new()
random::fill_bytes(buf, len: 16)
buf.len() == 16

fn fill_buffer(~buf: ByteBuffer, len: i32): Random -> void

Fills a byte buffer with cryptographically secure random bytes.

fn random_bool(): Random -> bool

Returns a random boolean value.

fn random_int(range: Range): Random -> i32

Returns a random integer within the provided range.
The range lower bound is inclusive. The upper bound follows Range:
exclusive by default, inclusive when include_end is true.
Example:
random::random_int(1..6) samples values in [1, 5].

Effects

eff Random

Host-provided random source effect.

The host random provider should use a secure entropy source when available.
std::random normalizes returned values into i32 byte ranges where needed.

Members
next_i64(tail) -> i64

Returns a random signed 64-bit integer.

fill_bytes(tail, len: i32) -> MsgPack

Returns an array of random byte values with length len.

Host values are expected to be i32 entries; callers should normalize each
element into the [0, 255] range before treating them as bytes.

mod std::result

Result standard module.

Re-exports the core Result type family and functional helpers.

Re-Exports

pub types::all

pub fns::all

mod std::result::fns

Result helper functions.

Functional constructors and combinators for working with Result<T, E>.

Functions

fn ok<T, E>(value: T): () -> Result<T, E>

Constructs a successful Result value.

Use this when an operation completes with a value.

Parameters
  • value

    Success value to wrap.

fn err<T, E>(error: E): () -> Result<T, E>

Constructs a failing Result value.

Use this when an operation cannot produce a success value.

Parameters
  • error

    Error value to wrap.

fn is_ok<T, E>(result: Result<T, E>): () -> bool

Returns true when the result is successful.

Parameters
  • result

    Result value to inspect.

fn is_err<T, E>(result: Result<T, E>): () -> bool

Returns true when the result is an error.

Parameters
  • result

    Result value to inspect.

fn unwrap_or<T, E>(result: Result<T, E>, fallback: T): () -> T

Returns the contained value or a fallback.

The fallback is returned unchanged when result is Err.

Parameters
  • result

    Result value to unwrap.

  • fallback

    Value returned for Err results.

fn map<T, E, U>( result: Result<T, E>, f: (v: T) -> U ) -> Result<U, E>

Transforms an Ok value and leaves Err unchanged.

Parameters
  • result

    Source result value.

  • f

    Mapping function applied only to Ok payloads.

fn and_then<T, E, U>( result: Result<T, E>, f: (v: T) -> Result<U, E> ) -> Result<U, E>

Chains another result-producing operation on success.

Errors are propagated without invoking f.

Parameters
  • result

    Source result value.

  • f

    Continuation invoked for Ok payloads.

mod std::result::types

Result type definitions.

Contains the sum type used to represent success (Ok) or failure (Err).

Type Aliases

type Result<T, E> = |(Ok<T>, Err<E>)

Result sum type.

A value is either Ok<T> for success or Err<E> for failure.

Objects

obj Unit

Unit sentinel type used by APIs that need a concrete object shape.

obj Ok<T>

Successful Result variant.

Stores the produced value for success paths.

Members
value: T

Successful payload value.

obj Err<E>

Failing Result variant.

Stores error information for failure paths.

Members
error: E

Error payload value.

mod std::set

Hash-based set collection backed by std::dict::Dict.
Values must implement DictKey so membership uses hash/equality semantics.

Objects

obj Set<T>

A hash-based set of unique values.

Example:
let ~tags = Set<String>::init()
tags.insert("alpha")
tags.contains("alpha")

impl<T> Set<T>

Members
init() -> Set<T>

Creates an empty set.

len(self: Set<T>) -> i32

Returns the number of values in the set.

is_empty(self: Set<T>) -> bool

Returns true when the set is empty.

contains(self: Set<T>, value: T) -> bool

Returns true when value is in the set.

insert(~self: Set<T>, value: T) -> bool

Inserts value, returning true only when it was newly inserted.

remove(~self: Set<T>, value: T) -> bool

Removes value, returning true only when it existed.

clear(~self: Set<T>) -> void

Removes all values.

values(self: Set<T>) -> Sequence<T>

Returns all values in unspecified order.

The returned sequence reflects hash-bucket traversal order, not insertion order.

mod std::string

Public string module surface.

This module re-exports the core string types and parse/error helpers from
std::string::type, and provides top-level constructors for UTF-8 data.
Use this module when you want the default string APIs without importing
implementation details.

Re-Exports

pub errors::ParseFloatError

pub errors::ParseIntError

pub errors::Utf8Error

pub index::StringIndex

pub type::CharSet

pub type::String

pub type::StringSlice

Functions

fn new_string(from_bytes: FixedArray<i32>): () -> String

Builds a string from owned UTF-8 byte storage without validation.

This constructor assumes from_bytes already contains UTF-8 data.
Invalid sequences are normalized into replacement runes by the lower-level
decoder used internally.

fn from_utf8(source: Array<i32>) -> Result<String, Utf8Error>

Validates UTF-8 bytes and builds a string on success.

  • source: UTF-8 bytes to validate and convert.

Example:
String::from_utf8([72, 101, 108, 108, 111])
returns Ok("Hello").

mod std::string::errors

Error payloads used by std::string parsing and UTF-8 conversion APIs.

Each error currently exposes a numeric code so callers can branch on
failure kinds without string matching.

Objects

obj Utf8Error

Error returned when UTF-8 validation fails.

Members
code: i32

Machine-readable error code.

obj ParseIntError

Error returned when integer parsing fails.

Members
code: i32

Machine-readable error code.

obj ParseFloatError

Error returned when floating-point parsing fails.

Members
code: i32

Machine-readable error code.

mod std::string::index

String index primitives.

A StringIndex is an opaque byte offset into a UTF-8 string.
Most callers should construct and move indices through String APIs like
start_index, end_index, index, and grapheme_index.

Objects

obj StringIndex

Opaque byte index used by string traversal APIs.

impl StringIndex

Members
to_i32(self: StringIndex) -> i32

Returns the raw integer byte offset for this index.

This is mainly useful for interop with low-level APIs.

mod std::string::type

Core UTF-8 string types and operations.

String is an owned UTF-8 value and StringSlice is a non-owning byte
window into a String. Index-based traversal uses StringIndex byte
offsets, with helpers that keep movement on rune or grapheme boundaries.

Type Aliases

type CharSet = Array<i32>

Rune set used by trimming and character membership APIs.

Objects

obj String

Owned UTF-8 string value.

impl String

Members
init() -> String

Creates an empty string.

with_capacity({ bytes _capacity: i32 }) -> String

Creates an empty string with capacity for at least _capacity bytes.

from_utf8(source: Array<i32>) -> Result<String, Utf8Error>

Validates UTF-8 bytes and builds a string on success.

  • source: byte array to validate as UTF-8.
byte_len(self: String): () -> i32

Returns the number of UTF-8 bytes.

rune_len(self: String): () -> i32

Returns the number of Unicode scalar values.

grapheme_len(self: String) -> i32

Returns the number of grapheme clusters.

is_empty(self: String) -> bool

Returns true when no values are stored.

to_utf8(self: String): () -> Array<i32>

Returns a UTF-8 byte array copy.

This allocates a new Array<i32> containing the exact encoded bytes.

Example:
String::from_utf8(text.to_utf8())
round-trips text through bytes validation.

to_string(self: String): () -> String

Returns this value as an owned string.

concat(self: String, other: String) -> String

Returns a new string by appending other.

concat(self: String, other: StringSlice) -> String

Returns a new string by appending other.

as_slice(self: String): () -> StringSlice

Returns a non-owning slice view of the string.

start_index(self: String): () -> StringIndex

Returns the first valid string index.

end_index(self: String): () -> StringIndex

Returns the index immediately after the last byte.

slice(self: String, range: Range) -> StringSlice

Returns a subrange view for the requested range.

  • range: byte-based range expression.

Start and end are clamped to valid bounds and moved to rune boundaries.
Empty or inverted ranges return an empty slice.

Example:
name.slice(0..4).to_string()
returns the first four bytes, snapped to rune boundaries.

slice(self: String, { range: Range }) -> StringSlice
index( self: String, { after cursor: StringIndex by steps?: i32 } ) -> Option<StringIndex>

Moves a string index by rune steps.

  • cursor: starting byte index.
  • steps: number of runes to move; defaults to 1.

Negative steps move backward. Returns None when cursor is invalid or
movement would go out of bounds.

Example:
text.index(after: text.start_index(), by: 2)
moves to the third rune boundary.

grapheme_index( self: String, { after cursor: StringIndex by steps?: i32 } ) -> Option<StringIndex>

Moves a string index by grapheme clusters.

  • cursor: starting byte index.
  • steps: number of grapheme clusters to move; defaults to 1.
graphemes(self: String) -> StringGraphemeSequence

Returns an iterator over grapheme slices.

get_byte(self: String, index: i32) -> Option<i32>

Returns the byte at the requested index, or None when the index is out of bounds.

raw_bytes(self: String): () -> FixedArray<i32>

Returns the underlying UTF-8 byte storage.

equals(self: String, other: String): () -> bool

Returns true when both strings have identical bytes.

==(self: String, other: String) -> bool

Compares two values for equality.

hash_i32(self: String): () -> i32

Returns a 32-bit hash of the string contents.

rune_at(self: String, index: i32) -> Option<i32>

Returns the rune at the requested rune index.

slice( self: String, { bytes start: i32 len: i32 } ): () -> String

Returns a substring using byte offsets.

slice_bytes(self: String, start: i32, len: i32): () -> String

Returns a substring using byte offsets.

slice( self: String, { runes start: i32 len: i32 } ): () -> String

Returns a substring using rune offsets.

slice_runes(self: String, start: i32, len: i32): () -> String

Returns a substring using rune offsets.

find_rune(self: String, rune: i32, { from?: StringIndex }) -> Option<StringIndex>

Returns the index of the first matching rune.

starts_with(self: String, prefix: StringSlice) -> bool

Returns true when the value begins with the provided prefix.

starts_with(self: String, prefix: String) -> bool

Returns true when the value begins with the provided prefix.

ends_with(self: String, suffix: StringSlice) -> bool

Returns true when the value ends with the provided suffix.

ends_with(self: String, suffix: String) -> bool

Returns true when the value ends with the provided suffix.

contains(self: String, substring: StringSlice) -> bool

Returns true when a matching value exists.

contains(self: String, substring: String) -> bool

Returns true when a matching value exists.

contains( self: String, { where pred: (rune: i32) -> bool } ) -> bool

Returns true when a matching value exists.

find(self: String, substring: StringSlice, { from?: StringIndex }) -> Option<StringIndex>

Returns the first value that satisfies the predicate.

find(self: String, substring: String, { from?: StringIndex }) -> Option<StringIndex>

Returns the first value that satisfies the predicate.

rfind(self: String, substring: StringSlice, { to?: StringIndex }) -> Option<StringIndex>

Returns the last match of a substring before the optional limit.

rfind(self: String, substring: String, { to?: StringIndex }) -> Option<StringIndex>

Returns the last match of a substring before the optional limit.

find_range(self: String, substring: StringSlice, { from?: StringIndex }) -> Option<Range>

Returns the start and end byte range of the first substring match.

find_range(self: String, substring: String, { from?: StringIndex }) -> Option<Range>

Returns the start and end byte range of the first substring match.

split_once(self: String, { on separator: i32 }): () -> Option<(String, String)>

Splits at the first matching separator.

split( self: String, { on separator: i32 max_splits?: i32 keep_empty?: bool } ) -> Array<StringSlice>

Splits a string by a delimiter or predicate.

split( self: String, { on separator: StringSlice max_splits?: i32 keep_empty?: bool } ) -> Array<StringSlice>

Splits a string by a delimiter or predicate.

split( self: String, { on separator: String max_splits?: i32 keep_empty?: bool } ) -> Array<StringSlice>

Splits a string by a delimiter or predicate.

split( self: String, { where pred: (rune: i32) -> bool max_splits?: i32 keep_empty?: bool } ) -> Array<StringSlice>

Splits a string by a delimiter or predicate.

lines(self: String, { keep_ends?: bool }) -> Array<StringSlice>

Splits a string slice into lines.

words(self: String) -> Array<StringSlice>

Splits the text into whitespace-delimited words.

trimmed(self: String): () -> String

Returns a trimmed copy.

trimmed(self: String, chars: CharSet) -> String

Returns a trimmed copy.

trim(~self: String) -> void

Trims leading and trailing characters in place.

trim(~self: String, chars: CharSet) -> void

Trims leading and trailing characters in place.

lowered(self: String): () -> String

Returns a lowercase ASCII copy of this string.

lower(~self: String) -> void

Converts this string in place to lowercase ASCII characters.

uppered(self: String): () -> String

Returns an uppercase ASCII copy of this string.

upper(~self: String) -> void

Converts this string in place to uppercase ASCII characters.

replaced( self: String, { old: String with replacement: String max_replacements?: i32 } ): () -> String

Returns a new string with replacements applied.

replace( ~self: String, { old: String with replacement: String max_replacements?: i32 } ) -> void

Replaces matching content with new content.

repeat(self: String, count: i32) -> String

Returns a new string repeated count times.

pad_left( self: String, { width: i32 with?: i32 } ) -> String

Returns a copy padded on the left to the requested width.

pad_right( self: String, { width: i32 with?: i32 } ) -> String

Returns a copy padded on the right to the requested width.

parse_int(self: String, { radix?: i32 }): () -> Result<i32, ParseIntError>

Parses this string as an i32.

  • radix: base in the inclusive range 2..36 (defaults to 10).

Supports optional leading + or -.

Error codes:

  • 1: invalid radix.
  • 2: empty input (or sign without digits).
  • 3: digit not valid for radix.
  • 4: value overflowed i32.

Example:
hex.parse_int(radix: 16) parses "ff" into 255.

parse_float(self: String): () -> Result<f64, ParseFloatError>

Parses this string as an f64.

Accepted format:
[+|-]?digits[.digits][e[+|-]digits]

Error codes:

  • 1: invalid or incomplete numeric format.

Example:
number.parse_float() parses "3.5e2" into 350.0.

to_debug(self: String) -> String

Returns a debug-friendly escaped string representation.

to_repr(self: String) -> String

Returns a source-like escaped string representation.

impl String for Sequence<i32>

Members
iter(self: String) -> Iterator<i32>

Returns an iterator over values.

obj StringSlice

Non-owning view into a String byte range.

impl StringSlice

Members
byte_len(self: StringSlice) -> i32

Returns the number of UTF-8 bytes.

is_empty(self: StringSlice) -> bool

Returns true when no values are stored.

to_string(self: StringSlice) -> String

Returns an owned string copy.

mod std::subscript

Subscript traits and range type.

Provides shared indexing contracts for read and write operations.

Objects

obj Range

Range object used by subscript-capable APIs.

Members
start: Optional<i32>

Optional inclusive starting index.

end: Optional<i32>

Optional ending index.

include_end: bool

Whether end is included in the range.

Traits

trait SubscriptRead<Index, Output>

Read-only subscript contract.

Members
subscript_get(self: <inferred>, index: Index) -> Output

Returns the value addressed by index.

trait SubscriptWrite<Index, Value>

Mutable subscript contract.

Members
subscript_set(~self: <inferred>, index: Index, value: Value) -> void

Writes value at index.

mod std::test

Re-Exports

pub assertions::all

mod std::test::assertions

Test assertion utilities.

Hosts effectful assertion helpers used by std and smoke tests.

Functions

fn assert(cond: boolean): fail -> void

Fails the current test when cond is false.

fn assert<T>(value: T, { eq expected: T }): fail -> void

Fails the current test when value is not equal to expected.

fn assert<T>(value: T, { neq expected: T }): fail -> void

Fails the current test when value is equal to expected.

Effects

eff Test

Host test-runner effect used by assertion helpers.

The runtime consumes these operations to mark test outcomes and emit test logs.

Members
fail(resume) -> void

Marks the current test as failed and stops normal assertion flow.

skip(resume) -> void

Marks the current test as skipped.

log(resume) -> void

Emits a structured test log event for the active test case.

mod std::time

Time primitives and scheduling helpers backed by the host Time effect.
Includes monotonic timing (Instant), wall-clock timing (SystemTime),
duration utilities, and timer-based callbacks.

Functions

fn sleep(ms: i64): Time -> Result<Unit, HostError>

Suspends execution for the provided millisecond count.
Example: time::sleep(250).

fn sleep(duration: Duration): Time -> Result<Unit, HostError>

Suspends execution for the provided duration.
Example: time::sleep(Duration::from_secs(1)).

fn on_timeout( duration: Duration, callback: (()) -> void ): Time -> Result<Unit, HostError>

Schedules and runs a callback once after the provided duration.
Example: time::on_timeout(Duration::from_millis(100), || do_work()).

fn on_interval( interval: Duration, callback: (()) -> void ): Time -> Result<Unit, HostError>

Runs a callback repeatedly at the provided interval.
The callback runs after each successful interval wait.
Example: time::on_interval(Duration::from_secs(1), || tick()).

Objects

obj Duration

Represents a millisecond-based time span.

impl Duration

Members
from_millis(ms: i64) -> Duration

Constructs a duration from milliseconds.

from_secs(s: i64) -> Duration

Constructs a duration from seconds.

as_millis(self: Duration) -> i64

Returns the duration in milliseconds.

as_secs(self: Duration) -> i64

Returns the duration in seconds.

obj Instant

Monotonic timestamp that is suitable for elapsed-time measurement.

impl Instant

Members
now(): Time -> Instant

Captures the current time value.

elapsed(self: Instant): Time -> Duration

Returns the duration since this instant was captured.

obj SystemTime

Wall-clock timestamp represented as milliseconds from the Unix epoch.

impl SystemTime

Members
now(): Time -> SystemTime

Captures the current time value.

unix_millis(self: SystemTime) -> i64

Returns milliseconds since the Unix epoch.

Effects

eff Time

Host-provided time and timer operations.

std::time encodes timer commands as MessagePack payloads and decodes host
responses into typed success/error values.

Members
monotonic_now_millis(tail) -> i64

Returns a monotonic millisecond timestamp suitable for elapsed-time math.

system_now_millis(tail) -> i64

Returns wall-clock milliseconds since Unix epoch.

sleep_millis(tail, ms: i64) -> MsgPack

Suspends execution for ms milliseconds.

Returns { ok: true } on success or { ok: false, code, message } on failure.

set_timeout_millis(tail, ms: i64) -> MsgPack

Creates a one-shot timer that fires once after ms milliseconds.

Returns { ok: true } or an error DTO.

set_interval_millis(tail, ms: i64) -> MsgPack

Creates a repeating timer using ms as the interval.

Returns { ok: true, value: timer_id } or an error DTO.

clear_timer(tail, timer_id: i64) -> MsgPack

Clears a timer created by set_timeout_millis or set_interval_millis.

timer_id must be the host-provided timer identifier.

mod std::traits

Core standard traits.

Re-exports shared behavior contracts used throughout the language and std.

Re-Exports

pub sequence::Sequence

pub sequence::Iterator

pub sequence::for

pub eq::Eq

pub ord::Ord

pub ord::Ordering

pub ord::Less

pub ord::Equal

pub ord::Greater

pub hash::Hash

pub hash::Hasher

pub default::Default

pub clone::Clone

pub clone::Copy

pub convert::From

pub convert::Into

pub convert::TryFrom

pub convert::TryInto

pub collect::Collect

Macros

macro for

mod std::traits::clone

Value duplication traits.

Clone supports explicit duplication, while Copy marks cheap copy semantics.

Traits

trait Clone<T>

Trait for creating an explicit duplicate of a value.

Members
clone(self: <inferred>) -> T

Returns a cloned value.

trait Copy<T>

Trait for values that can be copied without ownership transfer concerns.

Members
copy(self: <inferred>) -> T

Returns a copied value.

mod std::traits::collect

Collection construction traits.

Provides conversions from sequences into concrete collection types.

Traits

trait Collect<T>

Trait for creating a value from a sequence of items.

Members
from_sequence({ items: Sequence<T> }) -> Self

Builds Self from all items in items.

mod std::traits::convert

Conversion traits.

Provides infallible and fallible conversion contracts.

Traits

trait From<To, From>

Infallible conversion into To from From.

Members
from({ value: From }) -> To

Converts value into To.

trait Into<From, To>

Infallible conversion from From into To.

Members
into(self: <inferred>) -> To

Converts self into To.

trait TryFrom<To, From, E>

Fallible conversion into To from From.

Members
try_from({ value: From }) -> Result<To, E>

Attempts to convert value into To.

trait TryInto<From, To, E>

Fallible conversion from From into To.

Members
try_into(self: <inferred>) -> Result<To, E>

Attempts to convert self into To.

mod std::traits::default

Traits

trait Default<T>

Trait for producing a default instance of a type.

Members
default() -> T

Returns the default value for T.

mod std::traits::eq

Traits

trait Eq<T>

Trait for checking equality between two values of the same type.

Members
eq(self: <inferred>, { other: T }) -> bool

Returns true when self equals other.

ne(self: <inferred>, { other: T }) -> bool

Returns true when self does not equal other.

==(self: <inferred>, other: T) -> bool

Operator overload for equality checks.

!=(self: <inferred>, other: T) -> bool

Operator overload for inequality checks.

mod std::traits::hash

Hashing traits.

Defines writer and value hashing contracts used by hash-based collections.

Traits

trait Hasher

Trait implemented by hash state writers.

Members
write(self: <inferred>, { bytes: Array<i32> }) -> void

Writes bytes into the hasher state.

finish(self: <inferred>) -> i64

Finalizes hashing and returns the digest value.

trait Hash<T>

Trait for values that can feed bytes into a hasher.

Members
hash(self: <inferred>, { into: Hasher }) -> void

Writes this value into into.

mod std::traits::ord

Ordering trait and ordering marker types.

Defines total ordering comparisons and relational operator overloads.

Type Aliases

type Ordering = |(Less, |(Equal, Greater))

Union type representing a comparison result.

Objects

obj Less

Marker for values less than the compared value.

obj Equal

Marker for values equal to the compared value.

obj Greater

Marker for values greater than the compared value.

Traits

trait Ord<T>

Trait for total ordering between values.

Members
cmp(self: <inferred>, { other: T }) -> Ordering

Compares self with other and returns an Ordering marker.

<(self: <inferred>, other: T) -> bool

Operator overload for less-than checks.

<=(self: <inferred>, other: T) -> bool

Operator overload for less-than-or-equal checks.

>(self: <inferred>, other: T) -> bool

Operator overload for greater-than checks.

>=(self: <inferred>, other: T) -> bool

Operator overload for greater-than-or-equal checks.

mod std::traits::sequence

Sequence and iterator traits.

Defines iteration contracts and the for macro expansion used by the language.

Macros

macro for

Traits

trait Sequence<T>

Trait for values that can produce iterators.

Members
iter(self: <inferred>) -> Iterator<T>

Returns an iterator over sequence items.

trait Iterator<T>

Trait for stateful iterators over T values.

Members
next(~self: <inferred>) -> Option<T>

Produces the next item, or None when exhausted.

mod std::version

Version metadata for the standard library package.

Functions

fn std_version() -> String

Returns the version of the standard library package.

fn language_version() -> String

Returns the language version this standard library targets.

mod std::vx

Virtual DOM helpers.

Utilities for constructing VX element payloads encoded as MsgPack maps.

Functions

fn create_element( { name: String attributes?: Array<Array<MsgPack>> children: Array<MsgPack> } ) -> MsgPack

Creates a virtual DOM element payload for renderer consumption.

The returned value is a MsgPack map with name, children, and optional attributes.

Parameters
  • name

    Element tag or component identifier.

  • attributes

    Optional list of two-item key/value MsgPack pairs.

  • children

    Ordered child node payloads.