Skip to content
velt/native exports

velt/native

API reference

What the Velt side of a package with native code binds its Rust functions with. Programs that don't wrap a native library never import it. For a walkthrough, read the guide.

import { IoResult, IoStatus, unwrapIo, checkIo } from "velt/native";

Exports

Re-exported from velt/native/result

function unwrapIo<T>(r: IoResult<T>): T

The value of a successful result; throws IoError otherwise.

Re-exported from velt/native/status

function checkIo(s: IoStatus)

Throws IoError if the operation failed.

function

errorCodeName

#std/native/error.vlt:11

Re-exported from velt/native/error

function errorCodeName(code: i32): string

The Node-style name of a native function's failure code (code of a failed IoResult or IoStatus): "ENOENT", "ECONNREFUSED", "ETIMEDOUT", ...; what IoError.code holds.

Re-exported from velt/native/error

function ioError(code: i32, message: string): IoError

Builds the IoError for a failed result; takes ownership of the runtime's message.

Re-exported from velt/native/result

struct IoResult<T>

Result slot of a runtime operation producing a T (layout documented above).

FieldTypeDescription
code i32—
message string—
value T—

Re-exported from velt/native/status

Result slot of a runtime operation producing nothing (VeltErr).

FieldTypeDescription
code i32—
message string—