Part V · Complete Tooling, CLI & Standard Library Reference
Appendix B.4
Standard Library Reference: Reactor, Web, Zero-FFI SQLite & DBs, Scope, OTel, Flamegraphs, Desktop UI/Wayland/X11 & FFI
Complete AST-verified API reference for 32 networking, web, Zero-FFI SQLite & indexed KV, structured concurrency, OTel, profiling, UI/Wayland/X11, and FFI modules
Connected systems, databases, profiling & desktop UI stack: reactor, conc/scope, otel, profile/flamegraph, net/*, web, html, db/{sqlite,kv,query,postgres,redis,sidecar}, durable/*, tui, ui/{canvas,font,layout,widgets,wayland,x11}, ui, and opt-in ffi.
Module (use [...]) | Source File | Capabilities | Types | Functions |
|---|---|---|---|---|
codec/http3 | lib/codec/http3.vk | Zero host capabilities | 1 | 20 |
conc/scope | lib/conc/scope.vk | Zero host capabilities | 1 | 4 |
db/kv | lib/db/kv.vk | ..fs | 2 | 16 |
db/postgres | lib/db/postgres.vk | ..net, ..clocks | 7 | 34 |
db/query | lib/db/query.vk | Zero host capabilities | 1 | 8 |
db/redis | lib/db/redis.vk | ..net, ..clocks | 4 | 21 |
db/sidecar | lib/db/sidecar.vk | ..clocks, ..fs, ..exec | 2 | 7 |
db/sqlite | lib/db/sqlite.vk | ..fs | 5 | 23 |
durable/object | lib/durable/object.vk | ..clocks | 5 | 21 |
durable/workflow | lib/durable/workflow.vk | ..clocks | 3 | 22 |
durable | lib/durable.vk | Zero host capabilities | 0 | 8 |
ffi | lib/ffi.vk | ..env, ..fs, ..ffi | 2 | 15 |
html | lib/html.vk | Zero host capabilities | 1 | 42 |
net/client | lib/net/client.vk | ..clocks, ..net | 4 | 16 |
net/dns | lib/net/dns.vk | ..net, ..fs | 2 | 12 |
net/http2 | lib/net/http2.vk | Zero host capabilities | 3 | 15 |
net/http3 | lib/net/http3.vk | ..net, ..clocks | 2 | 24 |
net/ip | lib/net/ip.vk | Zero host capabilities | 2 | 8 |
net/tls13 | lib/net/tls13.vk | ..fs, ..net, ..clocks | 0 | 21 |
net/websocket | lib/net/websocket.vk | Zero host capabilities | 2 | 14 |
otel | lib/otel.vk | Zero host capabilities | 3 | 11 |
profile/flamegraph | lib/profile/flamegraph.vk | Zero host capabilities | 2 | 4 |
reactor | lib/reactor.vk | ..net, ..clocks | 4 | 34 |
tui | lib/tui.vk | Zero host capabilities | 3 | 36 |
ui/canvas | lib/ui/canvas.vk | Zero host capabilities | 2 | 31 |
ui/font | lib/ui/font.vk | Zero host capabilities | 0 | 8 |
ui/layout | lib/ui/layout.vk | Zero host capabilities | 4 | 13 |
ui/wayland | lib/ui/wayland.vk | Zero host capabilities | 2 | 20 |
ui/widgets | lib/ui/widgets.vk | Zero host capabilities | 14 | 82 |
ui/x11 | lib/ui/x11.vk | Zero host capabilities | 3 | 8 |
ui | lib/ui.vk | ..ui | 2 | 40 |
web | lib/web.vk | ..fs, ..net, ..clocks | 8 | 62 |
Module codec/http3
Exported Structs & Interfaces
H3Frame:H3Frame = struct { ftype i64, payload bytes }— Decoded HTTP/3 frame (ftype+payload).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
stream-control | stream-control = fn [] i64 | HTTP/3 unidirectional stream types (RFC 9114 Section 6.2). |
stream-push | stream-push = fn [] i64 | Exported codec/http3/stream-push operation. |
stream-qpack-encoder | stream-qpack-encoder = fn [] i64 | Exported codec/http3/stream-qpack-encoder operation. |
stream-qpack-decoder | stream-qpack-decoder = fn [] i64 | Exported codec/http3/stream-qpack-decoder operation. |
frame-data | frame-data = fn [] i64 | HTTP/3 frame types (RFC 9114 Section 7.2). |
frame-headers | frame-headers = fn [] i64 | Exported codec/http3/frame-headers operation. |
frame-cancel-push | frame-cancel-push = fn [] i64 | Exported codec/http3/frame-cancel-push operation. |
frame-settings | frame-settings = fn [] i64 | Exported codec/http3/frame-settings operation. |
frame-push-promise | frame-push-promise = fn [] i64 | Exported codec/http3/frame-push-promise operation. |
frame-goaway | frame-goaway = fn [] i64 | Exported codec/http3/frame-goaway operation. |
frame-max-push-id | frame-max-push-id = fn [] i64 | Exported codec/http3/frame-max-push-id operation. |
push-varint | push-varint = fn [mut out bytes, v i64] any | Appends a 62-bit non-negative QUIC/HTTP/3 variable-length integer onto out. |
encode-varint | encode-varint = fn [v i64] bytes | Encodes v into a standalone variable-length integer bytes slice. |
decode-varint | decode-varint = fn [b bytes, pos i64] any | Decodes one QUIC/HTTP/3 variable-length integer at pos, returning { val, next }. |
encode-frame | encode-frame = fn [f H3Frame] bytes | Encodes an HTTP/3 H3Frame (varint(type) || varint(length) || payload). |
decode-frame-at | decode-frame-at = fn [wire bytes, pos i64] any | Decodes a single HTTP/3 H3Frame at pos, returning { frame, next }. |
encode-settings-frame | encode-settings-frame = fn [settings map[i64]] bytes | Encodes HTTP/3 SETTINGS (map[i64] ID -> value) into a SETTINGS frame (0x04). |
decode-settings-payload | decode-settings-payload = fn [payload bytes] map[i64] | Decodes an HTTP/3 SETTINGS payload into map[i64]. |
qpack-encode | qpack-encode = fn [headers block[h2/Header]] bytes | Encodes headers (block[h2/Header]) into a stateless RFC 9204 QPACK field section (RIC = 0, Delta Base = 0). |
qpack-decode | qpack-decode = fn [field_bytes bytes] block[h2/Header] | Decodes an RFC 9204 QPACK field section (Required Insert Count == 0 static + literal + Huffman) into block[h2/Header]. |
Verified Doctest (codec/http3/encode-varint)
VEKO
use [h3 = codec/http3]
b1 = h3/encode-varint 37
b2 = h3/encode-varint 15293
b4 = h3/encode-varint 494878333
d1 = h3/decode-varint b1 0
d2 = h3/decode-varint b2 0
d4 = h3/decode-varint b4 0
if d1.val != 37 or d2.val != 15293 or d4.val != 494878333 [ err 'varint' ] else [ .ok ]Module conc/scope
Exported Structs & Interfaces
Scope:Scope = struct { tasks block }— Structured group of spawned task handles.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
new | new = fn [] Scope | Creates a new empty structured concurrency Scope. |
add | add = fn [mut s Scope, task_handle any] | Registers a spawned task handle (spawn [ ... ]) with s. |
await-all | await-all = fn [mut s Scope] block | Awaits all tasks in s in registration order, draining every handle even if an earlier task errored, and returns the ordered block of results (or the first err encountered). |
await-settled | await-settled = fn [mut s Scope] map | Awaits all tasks in s and returns { ok = block, errors = block } without short-circuiting. |
Verified Doctest (conc/scope/new)
VEKO
use [sc = conc/scope]
mut grp = sc/new
sc/add mut grp (spawn [ 10 + 11 ])
sc/add mut grp (spawn [ 20 + 1 ])
res = sc/await-all mut grp
if (len res) != 2 or res[0] != 21 or res[1] != 21 [ err 'scope await-all' ] else [ .ok ]Module db/kv
Exported Structs & Interfaces
KvStore:KvStore = struct { path str, fd i64, write_off i64, entries map[bytes], durable bool, wal_records i64 }— Open handle to an embedded crash-safe KV store.BatchOp:BatchOp = struct { op enum, key str, val bytes = ... }— Single batch mutation (op = .putor.del).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
open | open = fn [path str] KvStore | Opens or creates a durable (fsync-on-write) crash-safe KV store at path. |
open-fast | open-fast = fn [path str] KvStore | Opens or creates a KV store with deferred fsync (call kv/sync to flush durability). |
sync | sync = fn [db KvStore] enum | Flushes all buffered WAL writes to stable storage via os/fsync. |
close | close = fn [mut db KvStore] enum | Closes the underlying file descriptor. |
put-bytes | put-bytes = fn [mut db KvStore, key str, val bytes] enum | Stores raw bytes under key with CRC-32 WAL framing. |
get-bytes | get-bytes = fn [db KvStore, key str] bytes | Retrieves raw bytes for key, or returns err if absent (combine with /or). |
put-val | put-val = fn [mut db KvStore, key str, val any] enum | Stores any Veko value (i64, str, bytes, block, map, etc.) encoded via codec/vbin. |
get-val | get-val = fn [db KvStore, key str] any | Retrieves and decodes a codec/vbin value stored under key. |
delete | delete = fn [mut db KvStore, key str] enum | Deletes key by appending a tombstone WAL record. |
has? | has? = fn [db KvStore, key str] bool | Returns true if key currently exists in db. |
keys | keys = fn [db KvStore] block[str] | Returns all live keys in deterministic sorted order. |
scan-prefix | scan-prefix = fn [db KvStore, prefix str] block[str] | Returns all live keys starting with prefix in deterministic sorted order. |
batch | batch = fn [mut db KvStore, ops block[BatchOp]] enum | Atomically commits a batch of BatchOp puts/deletes in a single WAL write + fsync. |
put-sealed | put-sealed = fn [mut db KvStore, key str, enc_key32 bytes, plaintext bytes] enum | Encrypts plaintext with AES-256-GCM (crypto/seal, binding key as AAD) and stores the sealed envelope. |
with-open-sealed | with-open-sealed = fn [db KvStore, key str, enc_key32 bytes, use_fn fn[bytes->any]] any | Unseals an encrypted entry under enc_key32, passes plaintext to use_fn, and zeroizes it on exit. |
compact | compact = fn [mut db KvStore] enum | Compacts the WAL by rewriting only live keys into a temporary file, syncing, atomically renaming, and reopening. |
Verified Doctest (db/kv/open)
VEKO
use [kv = db/kv]
p = str/join [(os/temp-dir) '/veko_kv_doctest_1.vkkv'] ''
_ = os/remove/or p [.ok]
mut db = kv/open p
_ = kv/put-val mut db 'user:1' { name = 'Ada', score = 99 }
_ = kv/close mut db
mut db2 = kv/open p
u = kv/get-val db2 'user:1'
_ = kv/close mut db2
_ = os/remove/or p [.ok]
if u.name != 'Ada' or u.score != 99 [ err 'kv reopen' ] else [ .ok ]Module db/postgres
Exported Structs & Interfaces
PgMsg:PgMsg = struct { tag i64, body bytes }— Raw PostgreSQL v3 backend message (tagASCII byte +bodypayload).PgConn:PgConn = struct { stream io/Stream, server_params map[str], backend_pid i64, backend_key i64, tx_status i64, transport_kind enum = ... }— Connected PostgreSQL session state over anio/Stream.PgConfig:PgConfig = struct { host str = ..., port i64 = ..., user str = ..., password str = ..., database str = ..., ssl_mode enum = ..., tls_opts map = ..., connect_timeout dur = ..., io_timeout dur = ... }— Connection & TLS 1.3 configuration forconnectandnew-pool.PgPool:PgPool = struct { cfg PgConfig, max_conns i64, acquire_timeout dur = ..., max_idle_ns i64 = ..., health_check_ns i64 = ..., sem_ch any, idle_ch any }— Thread-safe channel-backed PostgreSQL connection pool (stores closure-free transport slots acrossspawnworkers).PgResult:PgResult = struct { columns block[str], rows block[block], command_tag str }— Query result containing column names, row data (stror.null), and command completion tag.ScramServerFirst:ScramServerFirst = struct { nonce str, salt bytes, iters i64, raw str }— Parsed SCRAM-SHA-256 server-first challenge fields.ScramProof:ScramProof = struct { client_final str, expected_server bytes }— Computed SCRAM-SHA-256 client-final proof + expected server signature.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode-startup | encode-startup = fn [user str, database str] bytes | Encodes a PostgreSQL v3.0 StartupMessage (len(u32) || 196608(u32) || k\0v\0... || \0). |
encode-msg | encode-msg = fn [tag i64, payload bytes] bytes | Encodes a typed PostgreSQL frontend message (tag(u8) || len(u32) || payload). |
encode-query | encode-query = fn [sql str] bytes | Encodes a Simple Query ('Q') message. |
encode-password | encode-password = fn [password str] bytes | Encodes a PasswordMessage ('p') for cleartext auth. |
encode-sasl-initial | encode-sasl-initial = fn [mech str, client_first bytes] bytes | Encodes a SASLInitialResponse ('p') selecting mech (e.g. 'SCRAM-SHA-256'). |
encode-sasl-response | encode-sasl-response = fn [client_final bytes] bytes | Encodes a SASLResponse ('p') carrying client-final bytes. |
encode-terminate | encode-terminate = fn [] bytes | Encodes a Terminate ('X') message. |
read-msg | read-msg = fn [mut stream io/Stream] PgMsg | Reads one PostgreSQL backend message (tag(1B) || len(4B) || body) from stream. |
decode-row-description | decode-row-description = fn [body bytes] block[str] | Decodes a RowDescription ('T') payload into a block of column names. |
decode-data-row | decode-data-row = fn [body bytes] block | Decodes a DataRow ('D') payload into a block of strings (or .null for SQL NULL). |
decode-error-fields | decode-error-fields = fn [body bytes] map[str] | Decodes an ErrorResponse ('E') or NoticeResponse ('N') payload into a field map. |
scram-client-first | scram-client-first = fn [user str, client_nonce str] str | Formats the SCRAM-SHA-256 client-first message ('n,,n=<user>,r=<nonce>'). |
scram-parse-server-first | scram-parse-server-first = fn [msg str] ScramServerFirst | Parses a SCRAM-SHA-256 server-first message ('r=<nonce>,s=<b64salt>,i=<iters>'). |
scram-compute-proof | scram-compute-proof = fn [password str, client_first str, sf ScramServerFirst] ScramProof | Computes the RFC 7677 SCRAM-SHA-256 client-final message and expected server signature. |
scram-verify-server-final | scram-verify-server-final = fn [server_final str, expected_server bytes] bool | Verifies the server-final SCRAM-SHA-256 message ('v=<b64sig>') in constant time. |
md5-password-hash | md5-password-hash = fn [user str, password str, salt4 bytes] str | Computes PostgreSQL's md5 password authenticator ('md5' + hex(md5(hex(md5(password + user)) + salt4))). |
encode-ssl-request | encode-ssl-request = fn [] bytes | Encodes PostgreSQL's 8-byte SSLRequest startup packet (len=8 || 80877103). |
connect-stream | connect-stream = fn [mut stream io/Stream, user str, password str, database str] PgConn | Performs the PostgreSQL v3.0 startup and authentication handshake over stream. |
query | query = fn [mut conn PgConn, sql str] PgResult | Executes a Simple Query ('Q') on conn and collects all returned rows until ReadyForQuery. |
close | close = fn [mut conn PgConn] enum | Sends a Terminate ('X') message and closes the underlying io/Stream. |
connect | connect = fn [cfg PgConfig] PgConn | Connects to PostgreSQL over TCP with optional SSLRequest -> TLS 1.3 upgrade (ssl_mode in .disable, .prefer, .require). |
encode-parse | encode-parse = fn [stmt_name str, sql str] bytes | Encodes a Parse ('P') frontend message for $1, $2, ... parameterized SQL. |
encode-bind | encode-bind = fn [portal_name str, stmt_name str, params block] bytes | Encodes a Bind ('B') frontend message binding params (str, i64, f64, bool, bytes, or .null). |
encode-describe-portal | encode-describe-portal = fn [portal_name str] bytes | Encodes a Describe ('D') message for portal portal_name. |
encode-execute | encode-execute = fn [portal_name str, max_rows i64] bytes | Encodes an Execute ('E') message (max_rows = 0 for all rows). |
encode-sync | encode-sync = fn [] bytes | Encodes a Sync ('S') message ending an Extended Query pipeline. |
query-params | query-params = fn [mut conn PgConn, sql str, params block] PgResult | Executes a SQL-injection-safe parameterized query ($1, $2, ...) using the Extended Query Protocol (Parse+Bind+Describe+Execute+Sync). |
prepare | prepare = fn [mut conn PgConn, stmt_name str, sql str] enum | Prepares a named server-side statement stmt_name for sql. |
query-prepared | query-prepared = fn [mut conn PgConn, stmt_name str, params block] PgResult | Executes a previously prepared statement stmt_name with params. |
rows-to-maps | rows-to-maps = fn [res PgResult] block[map] | Converts a PgResult into a block of maps keyed by res.columns. |
with-tx | with-tx = fn [mut conn PgConn, work_fn any] any | Runs (work_fn mut conn) inside a BEGIN / COMMIT / ROLLBACK transaction (automatically using SAVEPOINT when nested!). |
new-pool | new-pool = fn [cfg PgConfig, /max max_conns i64] PgPool | Creates a thread-safe PgPool bounded to max_conns concurrent connections (safe to share across spawn workers). |
with-conn | with-conn = fn [pool PgPool, work_fn any] any | Borrows a healthy PgConn from pool (validating health & rolling back dirty transactions), runs (work_fn mut conn), and returns it. |
close-pool | close-pool = fn [pool PgPool] i64 | Drains and closes all idle connections in pool. |
Verified Doctest (db/postgres/encode-startup)
VEKO
use [pg = db/postgres]
m = pg/encode-startup 'veko' 'appdb'
if (bytes/get-u32-be m 0) != (len m) or (bytes/get-u32-be m 4) != 196608 [ err 'pg startup' ] else [ .ok ]Module db/query
Exported Structs & Interfaces
Table:Table = struct { name str, pk_field str, indexed_fields block[str] }— Schema descriptor for a secondary-indexed KV table.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
define-table | define-table = fn [name str, pk_field str, indexed_fields block[str]] Table | Defines a logical Table over a kv/KvStore with primary-key field pk_field and indexed_fields. |
put-row | put-row = fn [mut db kv/KvStore, tbl Table, row map] enum | Inserts or updates row (a map containing tbl.pk_field), atomically updating all secondary indexes. |
get-row | get-row = fn [db kv/KvStore, tbl Table, pk str] any | Fetches a single row by primary key pk, or returns err if not found (combine with /or). |
delete-row | delete-row = fn [mut db kv/KvStore, tbl Table, pk str] enum | Deletes pk from tbl along with all of its secondary index entries atomically. |
scan-all | scan-all = fn [db kv/KvStore, tbl Table] block | Scans all rows in tbl in deterministic primary-key order. |
where-eq | where-eq = fn [db kv/KvStore, tbl Table, field str, value any] block | Queries all rows where row[field] == value (uses secondary index when field is indexed, or fallback scan). |
query-filter | query-filter = fn [db kv/KvStore, tbl Table, pred any, max_rows i64] block | Filters rows in tbl matching pred (fn [row] bool) with optional /limit max_rows. |
count-rows | count-rows = fn [db kv/KvStore, tbl Table] i64 | Counts total live rows in tbl. |
Verified Doctest (db/query/define-table)
VEKO
use [kv = db/kv, q = db/query]
p = str/join [(os/temp-dir) '/veko_db_query_doctest.vkkv'] ''
_ = os/remove/or p [.ok]
mut db = kv/open-fast p
users = q/define-table 'users' 'id' ['role' 'region']
_ = q/put-row mut db users { id = 'u1', name = 'Ada', role = 'admin', region = 'ca-west' }
_ = q/put-row mut db users { id = 'u2', name = 'Lin', role = 'dev', region = 'ca-west' }
_ = q/put-row mut db users { id = 'u3', name = 'Kai', role = 'admin', region = 'eu-north' }
admins = q/where-eq db users 'role' 'admin'
_ = kv/close mut db
_ = os/remove/or p [.ok]
if (len admins) != 2 or admins[0].name != 'Ada' or admins[1].name != 'Kai' [ err 'where-eq' ] else [ .ok ]Module db/redis
Exported Structs & Interfaces
DecodedResp:DecodedResp = struct { value any, consumed i64 }— Decoded RESP value along with the number of bytes consumed from the wire buffer.RedisClient:RedisClient = struct { stream io/Stream, rx_buf bytes, transport_kind enum = ... }— Connected Redis client wrapping anio/Streamand read buffer.RedisConfig:RedisConfig = struct { host str = ..., port i64 = ..., username str = ..., password str = ..., db i64 = ..., tls bool = ..., tls_opts map = ..., resp3 bool = ..., connect_timeout dur = ..., io_timeout dur = ... }— Connection, TLS 1.3, ACL authentication, and RESP3 negotiation options forconnectandnew-pool.RedisPool:RedisPool = struct { cfg RedisConfig, max_conns i64, acquire_timeout dur = ..., max_idle_ns i64 = ..., health_check_ns i64 = ..., sem_ch any, idle_ch any }— Thread-safe channel-backed Redis connection pool (safe to share acrossspawnworkers).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode-command | encode-command = fn [args block] bytes | Encodes a Redis command (block of strings) as a RESP array of bulk strings (*N\r\n$L\r\n...). |
encode-value | encode-value = fn [v any] bytes | Encodes a Veko value into RESP3 wire bytes (useful for both clients and mock/embedded RESP3 servers). |
decode-bytes | decode-bytes = fn [raw bytes] DecodedResp | Decodes one RESP3 / RESP2 value from raw bytes. |
from-stream | from-stream = fn [stream io/Stream] RedisClient | Wraps an io/Stream (TCP, TLS 1.3, or memory) in a RedisClient. |
cmd | cmd = fn [mut cli RedisClient, args block] any | Sends a single Redis command and returns the decoded RESP3/RESP2 reply (rejecting .secret leakage). |
ping | ping = fn [mut cli RedisClient] any | Sends PING (returns 'PONG'). |
get | get = fn [mut cli RedisClient, key str] any | Sends GET key (returns string or .null). |
set | set = fn [mut cli RedisClient, key str, val str] any | Sends SET key val. |
del | del = fn [mut cli RedisClient, key str] any | Sends DEL key. |
hset | hset = fn [mut cli RedisClient, key str, field str, val str] any | Sends HSET key field val. |
hget | hget = fn [mut cli RedisClient, key str, field str] any | Sends HGET key field. |
pipeline | pipeline = fn [mut cli RedisClient, cmds block[block]] block | Pipelines multiple commands in a single write and reads all replies in order. |
close | close = fn [mut cli RedisClient] enum | Closes the underlying io/Stream. |
set-ex | set-ex = fn [mut cli RedisClient, key str, val str, ttl_sec i64] any | Sends SET key val EX ttl_sec. |
incr | incr = fn [mut cli RedisClient, key str] any | Sends INCR key (returns incremented i64). |
expire | expire = fn [mut cli RedisClient, key str, ttl_sec i64] any | Sends EXPIRE key ttl_sec. |
connect | connect = fn [cfg RedisConfig] RedisClient | Connects to Redis over TCP or TLS 1.3 (cfg.tls == true), performing optional ACL AUTH, HELLO 3, and SELECT db. |
with-tx | with-tx = fn [mut cli RedisClient, work_fn any] any | Executes (work_fn mut cli) inside a MULTI / EXEC transaction (sending DISCARD if work_fn returns err). |
new-pool | new-pool = fn [cfg RedisConfig, /max max_conns i64] RedisPool | Creates a thread-safe RedisPool bounded to max_conns concurrent connections (safe across spawn workers). |
with-conn | with-conn = fn [pool RedisPool, work_fn any] any | Borrows a healthy RedisClient from pool (probing PING -> 'PONG' & auto-reconnecting on stale sockets), runs (work_fn mut cli), and returns it. |
close-pool | close-pool = fn [pool RedisPool] i64 | Drains and closes all idle connections in pool. |
Verified Doctest (db/redis/encode-command)
VEKO
use [redis = db/redis]
wire = redis/encode-command ['SET' 'k1' 'hello']
if (bytes/to-str wire) != '*3\r\n$3\r\nSET\r\n$2\r\nk1\r\n$5\r\nhello\r\n' [ err 'resp enc' ] else [ .ok ]Module db/sidecar
Exported Structs & Interfaces
SidecarReq:SidecarReq = struct { id i64, method str, params map }— Framed sidecar RPC request message.SidecarResp:SidecarResp = struct { id i64, ok bool, result any, error_msg str }— Framed sidecar RPC response message.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
encode-frame | encode-frame = fn [payload_val any] bytes | Encodes any Veko value into a 'VKSC' CRC-32-verified binary RPC frame. |
decode-frame | decode-frame = fn [wire bytes] any | Decodes and verifies a 'VKSC' CRC-32-framed codec/vbin payload. |
encode-req | encode-req = fn [req SidecarReq] bytes | Encodes a SidecarReq into a 'VKSC' frame. |
decode-req | decode-req = fn [wire bytes] SidecarReq | Decodes a 'VKSC' frame into a SidecarReq. |
encode-resp | encode-resp = fn [resp SidecarResp] bytes | Encodes a SidecarResp into a 'VKSC' frame. |
decode-resp | decode-resp = fn [wire bytes] SidecarResp | Decodes a 'VKSC' frame into a SidecarResp. |
call-exec | call-exec = fn [bin_path str, req SidecarReq] SidecarResp | Invokes an .exec-gated sidecar executable passing request/response frame file paths. |
Verified Doctest (db/sidecar/encode-frame)
VEKO
use [sc = db/sidecar]
req = sc/SidecarReq { id = 7, method = 'sql.query', params = { sql = 'SELECT 1' } }
wire = sc/encode-req req
dec = sc/decode-req wire
if dec.id != 7 or dec.method != 'sql.query' [ err 'sidecar roundtrip' ] else [ .ok ]Module db/sqlite
Exported Structs & Interfaces
ColumnDef:ColumnDef = struct { name str, col_type str = ..., is_pk bool = ..., is_int_pk bool = ..., is_unique bool = ..., is_indexed bool = ..., not_null bool = ..., has_default bool = ..., default_val any = ... }— Column schema definition in a SQLite table.IndexDef:IndexDef = struct { name str, table str, column str, is_unique bool = ..., sql str = ... }— Index metadata stored insqlite_schemaand backed by an index B-tree (0x0a/0x02).TableStore:TableStore = struct { name str, columns block[ColumnDef], sql str, next_id i64 = ..., row_ids block = ..., rows map = ..., idx_cache map = ... }— In-memory representation of a loaded/mutable SQLite table (rowid -> row map+ ordered rowids).TableSpec:TableSpec = struct { name str, pk_col str = ..., columns block[ColumnDef] }— Declarative homoiconic ORM model returned bydefine-table.SqliteDb:SqliteDb = struct { path str = ..., page_size i64 = ..., change_counter i64 = ..., schema_cookie i64 = ..., user_version i64 = ..., table_order block = ..., tables map = ..., index_order block = ..., indexes map = ..., in_tx bool = ..., tx_snapshot bytes = ..., raw_img bytes = ..., table_roots map = ..., index_roots map = ..., btree_dirty bool = ... }— Handle to an open pure-Veko SQLite 3 database (file-backed or:memory:).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
put-varint | put-varint = fn [mut buf bytes, v i64] | Exported db/sqlite/put-varint operation. |
read-varint | read-varint = fn [buf bytes, off i64] map | Exported db/sqlite/read-varint operation. |
seek-table-rowid | seek-table-rowid = fn [db_bytes bytes, page_size i64, usable_size i64, root_pg i64, target_rid i64] any | $O(\log N)$ binary-search lookup of a single target_rid directly across 0x05 interior & 0x0d leaf table B-tree pages. |
seek-index-btree | seek-index-btree = fn [db_bytes bytes, page_size i64, usable_size i64, pg_num i64, op str, target_val any, mut out_rids block] | $O(\log N + K)$ binary-search seek across 0x02 interior and 0x0a leaf SQLite index B-tree pages (=, <, <=, >, >=). |
to-bytes | to-bytes = fn [db SqliteDb] bytes | Exported db/sqlite/to-bytes operation. |
from-bytes | from-bytes = fn [raw bytes] SqliteDb | Decodes a standard binary SQLite 3 image (raw) into an in-memory SqliteDb. |
encode-rollback-journal | encode-rollback-journal = fn [orig_existed bool, page_size i64, orig_img bytes, new_img bytes] bytes | Builds a CRC-32-verified hot rollback journal (VKJRNL01) capturing all dirty/truncated original pages. |
verify-rollback-journal | verify-rollback-journal = fn [jraw bytes] map | Validates a VKJRNL01 hot rollback journal image and returns { orig_existed, page_size, orig_size, records } or err. |
recover-journal | recover-journal = fn [db_path str] enum | Replays and cleans up any hot rollback journal (<db_path>-journal) left by an interrupted commit. |
open | open = fn [path str] SqliteDb | Opens an existing .sqlite / .db file from disk (automatically recovering <path>-journal if present), creates a new file-backed database if it doesn't exist yet, or creates an in-memory database when path == ':memory:'. |
save | save = fn [mut db SqliteDb] enum | Atomically flushes db to disk using a CRC-32 hot rollback journal (<path>-journal) + os/pwrite + os/fsync. |
close | close = fn [mut db SqliteDb] enum | Saves (if file-backed) and closes db. |
tables | tables = fn [db SqliteDb] block[str] | Lists all user table names in db. |
indexes | indexes = fn [db SqliteDb] block[str] | Lists all user index names in db. |
exec | exec = fn [mut db SqliteDb, sql str, params block] any | Executes a DDL, transaction, or DML SQL statement (CREATE TABLE, CREATE [UNIQUE] INDEX, ALTER TABLE ADD COLUMN, DROP TABLE, INSERT, UPDATE, DELETE, BEGIN, COMMIT, ROLLBACK). Returns affected row count (or last inserted rowid on single-row INSERT). |
query-sql | query-sql = fn [db SqliteDb, sql str, params block] block | Executes a parameterized SELECT query (? placeholders, optional INNER JOIN / LEFT JOIN) and returns a block of row maps. |
define-table | define-table = fn [table_name str, spec_blk block] TableSpec | Defines a declarative ORM TableSpec from a homoiconic (quote [...]) schema block: define-table 'users' (quote [id i64 .pk, email str .unique, role str = 'member', score i64 = 0]) |
migrate | migrate = fn [mut db SqliteDb, spec TableSpec] enum | Creates or auto-migrates spec on db (CREATE TABLE IF NOT EXISTS, ALTER TABLE ADD COLUMN for new fields, and CREATE [UNIQUE] INDEX IF NOT EXISTS). |
insert | insert = fn [mut db SqliteDb, spec TableSpec, record any] i64 | Inserts a record map / struct into spec and returns the inserted rowid (i64). |
find-by-id | find-by-id = fn [db SqliteDb, spec TableSpec, id any] map | Looks up a single record by primary key (err if not found, ready for /or). |
update-by-id | update-by-id = fn [mut db SqliteDb, spec TableSpec, id any, patch map] i64 | Updates fields in patch on the record matching id, returning updated row count. |
delete-by-id | delete-by-id = fn [mut db SqliteDb, spec TableSpec, id any] i64 | Deletes the record matching id, returning deleted row count. |
q | q = fn [db SqliteDb, dsl block] block | Executes a homoiconic Veko query dialect block against db: sqlite/q db (quote [select [u.email o.total] from users u join orders o on [u.id == o.user_id] where [o.total >= 50] order-by [o.total .desc] limit 10]) |
Verified Doctest (db/sqlite/exec)
VEKO
use [sq = db/sqlite]
mut db = sq/open ':memory:'
_ = sq/exec mut db 'CREATE TABLE nodes (id INTEGER PRIMARY KEY, host TEXT UNIQUE, port INTEGER DEFAULT 443)' []
id1 = sq/exec mut db 'INSERT INTO nodes (host, port) VALUES (?, ?)' ['edge.veko-lang.org' 8443]
_ = sq/exec mut db 'ALTER TABLE nodes ADD COLUMN region TEXT DEFAULT \'ca-central\'' []
raw = sq/to-bytes db
db2 = sq/from-bytes raw
rows = sq/query-sql db2 'SELECT host, port, region FROM nodes WHERE id = ?' [id1]
if (len rows) != 1 or rows[0].port != 8443 or rows[0].region != 'ca-central' [ err 'sqlite roundtrip failed' ] else [ .ok ]Module durable/object
Exported Structs & Interfaces
ObjectRef:ObjectRef = struct { ns str, id str, version i64 = ..., alarm_ns i64 = ... }— Reference to a persistent named Durable Object inside adb/kvstore.AlarmEvent:AlarmEvent = struct { ns str, id str, fire_at_ns i64, tag str }— One due durable alarm returned bypoll-due-alarms.InboxMsg:InboxMsg = struct { seq i64, sent_ns i64, kind str, payload any, attempts i64 = ... }— One queued durable inbox message returned bydrain-inbox/process-inbox.InboxOpts:InboxOpts = struct { max_attempts i64 = ..., base_backoff dur = ..., max_backoff dur = ..., batch_limit i64 = ... }— Retry, visibility backoff, and batch limits forprocess-inbox.DeadLetterMsg:DeadLetterMsg = struct { ns str, id str, seq i64, kind str, payload any, attempts i64, last_error str, failed_ns i64 }— Persistent Dead-Letter Queue (DLQ) record created when an inbox message exhaustsmax_attempts.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
open-object | open-object = fn [mut db kv/KvStore, ns str, id str] ObjectRef | Opens or creates a Durable Object identified by (ns, id) in db. |
get | get = fn [db kv/KvStore, obj ObjectRef, field str] any | Reads a single durable state field from obj (returns err if absent; combine with /or). |
get-or | get-or = fn [db kv/KvStore, obj ObjectRef, field str, fallback any] any | Reads a single durable state field from obj, returning fallback when absent. |
put-field | put-field = fn [mut db kv/KvStore, mut obj ObjectRef, field str, val any] enum | Atomically writes one field and increments the object's version in a single db/kv batch. |
put-fields | put-fields = fn [mut db kv/KvStore, mut obj ObjectRef, fields map] enum | Atomically writes every key/value pair in fields and bumps the object's version in one WAL batch. |
delete-field | delete-field = fn [mut db kv/KvStore, mut obj ObjectRef, field str] enum | Atomically deletes a state field and bumps the object's version. |
state | state = fn [db kv/KvStore, obj ObjectRef] map | Loads all current state fields of obj as a map. |
mutate | mutate = fn [mut db kv/KvStore, mut obj ObjectRef, handler any] any | Executes a transactional actor turn (handler cur_state): - If handler returns err, zero writes are committed (full atomic rollback). - Otherwise handler returns { state = updated_map, result = value }, whose changed/deleted keys and incremented version are committed atomically in a single db/kv batch. |
mutate-cas | mutate-cas = fn [mut db kv/KvStore, mut obj ObjectRef, expected_version i64, handler any] any | Optimistic Compare-And-Swap (CAS) transactional mutation: verifies on-disk version == expected_version before committing. |
set-alarm-at | set-alarm-at = fn [mut db kv/KvStore, mut obj ObjectRef, fire_at_ns i64, tag str] enum | Schedules a persistent alarm for obj firing at absolute Unix timestamp fire_at_ns. |
set-alarm | set-alarm = fn [mut db kv/KvStore, mut obj ObjectRef, delay dur, tag str] i64 | Schedules a persistent alarm firing after delay from now (time/unix). |
clear-alarm | clear-alarm = fn [mut db kv/KvStore, mut obj ObjectRef] enum | Cancels any pending durable alarm on obj. |
poll-due-alarms | poll-due-alarms = fn [mut db kv/KvStore, ns str] block[AlarmEvent] | Scans namespace ns for alarms with fire_at_ns <= time/unix, atomically clears them, and returns them. |
enqueue | enqueue = fn [mut db kv/KvStore, mut obj ObjectRef, kind str, payload any] i64 | Enqueues a durable FIFO message into obj's mailbox and returns its monotonic sequence number. |
enqueue-batch | enqueue-batch = fn [mut db kv/KvStore, mut obj ObjectRef, messages block] i64 | Enqueues a block of { kind, payload } messages into obj's mailbox in a single db/kv WAL batch. |
drain-inbox | drain-inbox = fn [mut db kv/KvStore, mut obj ObjectRef] block[InboxMsg] | Atomically drains and returns all pending FIFO messages in obj's mailbox. |
process-inbox | process-inbox = fn [mut db kv/KvStore, mut obj ObjectRef, opts InboxOpts, handler any] map | Transactionally processes visible inbox messages via (handler state msg) with exponential visibility backoff and automatic Dead-Letter Queue (do_dlq/<ns>/<id>/<seq>) routing on exhausted max_attempts, committing all state changes + ACKs + retries + DLQ moves in a single atomic db/kv WAL batch. |
list-dead-letters | list-dead-letters = fn [db kv/KvStore, obj ObjectRef] block[DeadLetterMsg] | Lists all Dead-Letter Queue (DeadLetterMsg) records for obj. |
requeue-dead-letter | requeue-dead-letter = fn [mut db kv/KvStore, mut obj ObjectRef, seq i64] bool | Atomically moves dead-lettered message seq back into obj's live inbox with attempts = 0. |
list-ids | list-ids = fn [db kv/KvStore, ns str] block[str] | Lists all Durable Object IDs currently stored under namespace ns. |
destroy | destroy = fn [mut db kv/KvStore, obj ObjectRef] enum | Atomically deletes all state, metadata, alarms, and queued messages belonging to obj. |
Verified Doctest (durable/object/open-object)
VEKO
use [kv = db/kv, dobj = durable/object]
p = str/join [(os/temp-dir) '/veko_do_doctest_1.vkkv'] ''
_ = os/remove/or p [.ok]
mut db = kv/open-fast p
mut obj = dobj/open-object mut db 'cart' 'user-42'
_ = dobj/put-field mut db mut obj 'total' 199
_ = kv/close mut db
mut db2 = kv/open-fast p
obj2 = dobj/open-object mut db2 'cart' 'user-42'
tot = dobj/get db2 obj2 'total'
_ = kv/close mut db2
_ = os/remove/or p [.ok]
if tot != 199 or obj2.version != 1 [ err 'durable object persistence failed' ] else [ .ok ]Module durable/workflow
Exported Structs & Interfaces
WorkflowRun:WorkflowRun = struct { id str, name str, status enum = ..., step_count i64 = ..., wait_event str = ..., wake_at_ns i64 = ... }— Active handle to a durable workflow execution instance.RetryPolicy:RetryPolicy = struct { max_attempts i64 = ..., base_delay dur = ..., max_delay dur = ..., route_to_dlq bool = ... }— Exponential backoff + Dead-Letter Queue policy forstep-retry-policy.StepSpec:StepSpec = struct { name str, work any }— Named step descriptor for single-fsync batched execution (step-batch).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
start | start = fn [mut db kv/KvStore, id str, name str, input any] WorkflowRun | Starts a new durable workflow run id, or idempotently resumes an existing run after a crash/restart. |
get-status | get-status = fn [db kv/KvStore, id str] map | Returns the full persisted metadata map for workflow id. |
step-done? | step-done? = fn [db kv/KvStore, wf WorkflowRun, step_name str] bool | Returns true if step_name has already been checkpointed as completed in db. |
step-result | step-result = fn [db kv/KvStore, wf WorkflowRun, step_name str] any | Returns the persisted checkpoint result for a completed step_name, or err if not done. |
step | step = fn [mut db kv/KvStore, mut wf WorkflowRun, step_name str, work_fn any] any | Executes a durable, replay-safe memoized step step_name: - On replay (if step_name already completed in db), immediately returns its persisted value without invoking work_fn. - Otherwise calls (work_fn), atomically checkpoints its result to db/kv, and returns it. |
step-with-retry | step-with-retry = fn [mut db kv/KvStore, mut wf WorkflowRun, step_name str, max_attempts i64, backoff dur, work_fn any] any | Executes a durable step with up to max_attempts retries and backoff delay between failures. Completed steps are memoized in db/kv and never re-run on replay. |
sleep-until | sleep-until = fn [mut db kv/KvStore, mut wf WorkflowRun, step_name str, delay dur] bool | Durable sleep checkpoint: persists a wake-up timestamp on first invocation and returns false until time/unix >= wake_at_ns, after which it checkpoints done = true and returns true. |
wait-event | wait-event = fn [mut db kv/KvStore, mut wf WorkflowRun, event_name str] map | Waits for an external signal event_name: - If already delivered via send-event, returns { ready = true, payload = ... }. - Otherwise persists status = 'waiting' and returns { ready = false, payload = .null }. |
send-event | send-event = fn [mut db kv/KvStore, id str, event_name str, payload any] enum | Durably delivers an external event event_name with payload to workflow id. |
record-compensation | record-compensation = fn [mut db kv/KvStore, mut wf WorkflowRun, comp_name str, data any] enum | Registers a durable LIFO saga compensation entry (comp_name, data) on wf. |
run-compensations | run-compensations = fn [mut db kv/KvStore, mut wf WorkflowRun, comp_fn any] i64 | Executes all registered compensations in LIFO order by invoking (comp_fn name data), clears them atomically, marks the workflow .compensated, and returns the count executed. |
complete | complete = fn [mut db kv/KvStore, mut wf WorkflowRun, output any] enum | Atomically marks wf as .completed and persists output. |
fail | fail = fn [mut db kv/KvStore, mut wf WorkflowRun, reason str] enum | Atomically marks wf as .failed and persists reason. |
history | history = fn [db kv/KvStore, id str] block | Returns the chronological durable execution log entries for workflow id. |
list-runs | list-runs = fn [db kv/KvStore] block[str] | Lists all workflow run IDs stored in db. |
step-retry-policy | step-retry-policy = fn [mut db kv/KvStore, mut wf WorkflowRun, step_name str, policy RetryPolicy, work_fn any] any | Executes a durable step with exponential backoff (RetryPolicy) and automatic Dead-Letter Queue (wf_dlq/<id>) routing on exhaustion. |
list-dead-letters | list-dead-letters = fn [db kv/KvStore] block[map] | Lists all dead-lettered workflow records stored under wf_dlq/*. |
requeue-dead-letter | requeue-dead-letter = fn [mut db kv/KvStore, id str] WorkflowRun | Atomically clears the failed step's attempt counter and moves workflow id out of the Dead-Letter Queue so replay resumes at the failed step. |
step-batch | step-batch = fn [mut db kv/KvStore, mut wf WorkflowRun, specs block[StepSpec]] block | Executes a batch of StepSpecs, skipping already-memoized steps on replay and checkpointing all newly completed steps in ONE db/kv WAL batch (fsync). |
wait-event-timeout | wait-event-timeout = fn [mut db kv/KvStore, mut wf WorkflowRun, event_name str, timeout dur] map | Waits for external signal event_name up to timeout ({ ready = bool, timed_out = bool, payload = any }). |
poll-runnable | poll-runnable = fn [db kv/KvStore] block[str] | Scans db for workflows ready to execute (status == 'running' or waiting timers/deadlines with wake_at_ns <= time/unix). |
claim-run | claim-run = fn [mut db kv/KvStore, id str, worker_id str, lease_dur dur] bool | Atomically acquires or renews a distributed worker execution lease (worker_id, lease_dur) on workflow id. |
Verified Doctest (durable/workflow/start)
VEKO
use [kv = db/kv, wf = durable/workflow]
p = str/join [(os/temp-dir) '/veko_wf_doctest_1.vkkv'] ''
_ = os/remove/or p [.ok]
mut db = kv/open-fast p
mut run = wf/start mut db 'order-1' 'checkout' { total = 49 }
v1 = wf/step mut db mut run 'charge' fn [] [ 'tx-100' ]
// Re-open and replay: completed step returns persisted 'tx-100' without running closure!
_ = kv/close mut db
mut db2 = kv/open-fast p
mut run2 = wf/start mut db2 'order-1' 'checkout' { total = 49 }
v2 = wf/step mut db2 mut run2 'charge' fn [] [ 'tx-999-must-not-run' ]
_ = wf/complete mut db2 mut run2 v2
_ = kv/close mut db2
_ = os/remove/or p [.ok]
if v1 != 'tx-100' or v2 != 'tx-100' or run2.status != .completed [ err 'replay violated idempotency' ] else [ .ok ]Module durable
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
open-store | open-store = fn [path str] kv/KvStore | Opens a durable fsync-backed db/kv backing store for Durable Objects and Workflows. |
open-store-fast | open-store-fast = fn [path str] kv/KvStore | Opens a high-throughput WAL-backed db/kv store (for tests and ephemeral workloads). |
close-store | close-store = fn [mut db kv/KvStore] enum | Closes a db/kv backing store cleanly. |
object | object = fn [mut db kv/KvStore, ns str, id str] dobj/ObjectRef | Opens or creates a Durable Object (ns, id). |
workflow | workflow = fn [mut db kv/KvStore, id str, name str, input any] dwf/WorkflowRun | Starts or idempotently resumes a Durable Workflow run id. |
poll-workflows | poll-workflows = fn [db kv/KvStore] block[str] | Scans db for runnable or timer-due Durable Workflows. |
claim-workflow | claim-workflow = fn [mut db kv/KvStore, id str, worker_id str, lease_dur dur] bool | Claims a distributed worker lease on workflow id. |
workflow-dead-letters | workflow-dead-letters = fn [db kv/KvStore] block[map] | Lists all Dead-Letter Queue workflow entries in db. |
Module ffi
Exported Structs & Interfaces
Library:Library = struct { handle i64, path str }— Handle to a dynamically loaded foreign shared library.Symbol:Symbol = struct { addr i64, name str }— Handle to a resolved foreign C symbol pointer.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
candidate-paths | candidate-paths = fn [name str, veko_lib_env str, is_win bool] block[str] | Splits VEKO_LIB on ; (Windows) or : (POSIX) and returns candidate shared-library paths before falling back to name for standard OS dynamic loader resolution. |
resolve-lib-path | resolve-lib-path = fn [name str] str | Resolves name against VEKO_LIB directories on disk when present, otherwise returns name. |
open-lib | open-lib = fn [path str] Library | Opens a foreign shared library (LoadLibraryA on Windows, dlopen on Linux/macOS), searching VEKO_LIB directories first when configured. Requires opt-in .ffi capability. |
resolve | resolve = fn [lib Library, name str] Symbol | Resolves a C symbol inside lib (GetProcAddress on Windows, dlsym on Linux/macOS). |
call-c | call-c = fn [s Symbol, args block] i64 | Invokes a foreign C function s with up to 6 integer/string/bytes/bool arguments using the platform's static AOT C-ABI trampoline and returns its i64 result register. |
close-lib | close-lib = fn [lib Library] | Closes a loaded foreign library (FreeLibrary / dlclose). |
pack-i32 | pack-i32 = fn [mut buf bytes, v i64] | Appends a 32-bit little-endian integer into buf. |
pack-u32 | pack-u32 = fn [mut buf bytes, v i64] | Appends an unsigned 32-bit little-endian integer into buf. |
pack-i64 | pack-i64 = fn [mut buf bytes, v i64] | Appends a 64-bit little-endian integer into buf. |
pack-cstr | pack-cstr = fn [mut buf bytes, s str] | Appends a NUL-terminated UTF-8 C string into buf. |
pad-align | pad-align = fn [mut buf bytes, align i64] | Appends pad zero bytes to align a C struct field to align bytes. |
unpack-u32 | unpack-u32 = fn [buf bytes, off i64] i64 | Reads an unsigned 32-bit little-endian integer at byte offset off. |
unpack-i32 | unpack-i32 = fn [buf bytes, off i64] i64 | Reads a signed 32-bit little-endian integer at byte offset off. |
unpack-i64 | unpack-i64 = fn [buf bytes, off i64] i64 | Reads a 64-bit little-endian integer at byte offset off. |
unpack-cstr | unpack-cstr = fn [buf bytes, off i64] str | Reads a NUL-terminated C string starting at off. |
Verified Doctest (ffi/candidate-paths)
VEKO
use [ffi]
cands = ffi/candidate-paths 'custom_ext' '/opt/veko/lib:/usr/local/lib' falseModule html
Exported Structs & Interfaces
Node:Node = struct { kind enum, tag str = ..., attrs map = ..., children block = ..., content str = ... }— Typed HTML DOM node (.el,.text,.raw,.frag,.comment,.doctype).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
escape | escape = fn [s str] str | Escapes HTML text content (&, <, >, ", ') to prevent XSS. |
el | el = fn [tag any, attrs map, children block] Node | Creates an HTML element node (accepts either .div enum or 'div' string tag). |
text | text = fn [s str] Node | Creates an auto-escaped text node. |
raw | raw = fn [trusted_html str] Node | Creates a trusted unescaped raw HTML/SVG node (never pass untrusted user input!). |
frag | frag = fn [children block] Node | Creates a document fragment grouping multiple children without a wrapper element. |
comment | comment = fn [s str] Node | Creates an HTML comment node (<!-- ... -->). |
doctype | doctype = fn [] Node | Creates an HTML5 <!DOCTYPE html> preamble node. |
div | div = fn [attrs map, children block] Node | Ergonomic HTML5 element helpers for typed pure-Veko components. |
span | span = fn [attrs map, children block] Node | Exported html/span operation. |
p | p = fn [attrs map, children block] Node | Exported html/p operation. |
a | a = fn [attrs map, children block] Node | Exported html/a operation. |
h1 | h1 = fn [attrs map, children block] Node | Exported html/h1 operation. |
h2 | h2 = fn [attrs map, children block] Node | Exported html/h2 operation. |
h3 | h3 = fn [attrs map, children block] Node | Exported html/h3 operation. |
ul | ul = fn [attrs map, children block] Node | Exported html/ul operation. |
ol | ol = fn [attrs map, children block] Node | Exported html/ol operation. |
li | li = fn [attrs map, children block] Node | Exported html/li operation. |
section | section = fn [attrs map, children block] Node | Exported html/section operation. |
article | article = fn [attrs map, children block] Node | Exported html/article operation. |
header | header = fn [attrs map, children block] Node | Exported html/header operation. |
footer | footer = fn [attrs map, children block] Node | Exported html/footer operation. |
nav | nav = fn [attrs map, children block] Node | Exported html/nav operation. |
main-el | main-el = fn [attrs map, children block] Node | Exported html/main-el operation. |
form | form = fn [attrs map, children block] Node | Exported html/form operation. |
label | label = fn [attrs map, children block] Node | Exported html/label operation. |
button | button = fn [attrs map, children block] Node | Exported html/button operation. |
table | table = fn [attrs map, children block] Node | Exported html/table operation. |
thead | thead = fn [attrs map, children block] Node | Exported html/thead operation. |
tbody | tbody = fn [attrs map, children block] Node | Exported html/tbody operation. |
tr | tr = fn [attrs map, children block] Node | Exported html/tr operation. |
th | th = fn [attrs map, children block] Node | Exported html/th operation. |
td | td = fn [attrs map, children block] Node | Exported html/td operation. |
input | input = fn [attrs map] Node | Exported html/input operation. |
img | img = fn [attrs map] Node | Exported html/img operation. |
br | br = fn [] Node | Exported html/br operation. |
hr | hr = fn [] Node | Exported html/hr operation. |
meta-tag | meta-tag = fn [attrs map] Node | Exported html/meta-tag operation. |
link-css | link-css = fn [href str] Node | Exported html/link-css operation. |
style-el | style-el = fn [css str] Node | Exported html/style-el operation. |
script | script = fn [attrs map, js str] Node | Exported html/script operation. |
document | document = fn [title str, head_extra block, body_children block] Node | Builds a complete HTML5 <!DOCTYPE html> document with <meta charset="utf-8">, viewport, <title>, optional head_extra nodes, and body_children. |
render | render = fn [node any] str | Renders any typed html/Node, Hiccup block ([.div { class = 'x' } ['hi']]), or nested component tree into an HTML string. |
Verified Doctest (html/escape)
VEKO
use [html]
if (html/escape '<script>alert("x")</script>') != '<script>alert("x")</script>' [
err 'escape'
] else [ .ok ]Module net/client
Exported Structs & Interfaces
RequestOpts:RequestOpts = struct { headers map[str] = ..., timeout dur = ..., max_redirects i64 = ..., roots_pem str = ..., extra_roots_pem str = ..., ca_file str = ..., pins_sha256 block = ..., pqc bool = ... }— Request options with ergonomic defaults.HttpResponse:HttpResponse = struct { status i64, reason str, headers map[str], body bytes, final_url str }— Structured HTTP response returned byrequest,get,post, andpost-json.AsyncRequest:AsyncRequest = struct { method str = ..., url str, headers map[str] = ..., body bytes = ..., timeout dur = ... }— Descriptor for one concurrent non-blocking HTTP/1.1 request inrequest-batch.Pool:Pool = struct { idle map, max_idle i64 = ..., reused i64 = ... }— Reusable HTTP/1.1 keep-alive connection pool keyed byscheme://host:port.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
bearer-header | bearer-header = fn [token str] map[str] | Returns a header map with Authorization: Bearer <token>. |
basic-header | basic-header = fn [user str, password str] map[str] | Returns a header map with RFC 7617 Authorization: Basic <base64(user:pass)>. |
header | header = fn [resp HttpResponse, name str, default_val str] str | Looks up a response header case-insensitively (returns default_val if absent). |
text-body | text-body = fn [resp HttpResponse] str | Returns the response body decoded as a UTF-8 string. |
json-body | json-body = fn [resp HttpResponse] any | Decodes the response body as JSON. |
request | request = fn [method str, target_url str, body bytes, opts RequestOpts] HttpResponse | Executes an HTTP/HTTPS request with redirect handling (301/302/303/307/308). |
get | get = fn [target_url str, opts RequestOpts] HttpResponse | Performs an HTTP/HTTPS GET request. |
head | head = fn [target_url str, opts RequestOpts] HttpResponse | Performs an HTTP/HTTPS HEAD request (returns headers with empty body, preserving Content-Length). |
post | post = fn [target_url str, body bytes, opts RequestOpts] HttpResponse | Performs an HTTP/HTTPS POST request with raw body bytes. |
post-json | post-json = fn [target_url str, payload any, opts RequestOpts] HttpResponse | JSON-encodes payload and sends an HTTP/HTTPS POST with Content-Type: application/json. |
request-batch | request-batch = fn [reqs block[AsyncRequest]] block | Executes a batch of HTTP/1.1 AsyncRequests concurrently on a single OS readiness reactor (epoll / kqueue / IOCP+WSAPoll / WASI net-poll) using non-blocking sockets. Returns a block in matching input order where each entry is an HttpResponse or err. |
get-many | get-many = fn [urls block[str], opts RequestOpts] block | Performs concurrent non-blocking HTTP GET requests for all urls on a single reactor thread. |
new-pool | new-pool = fn [cap i64] Pool | Creates a new empty HTTP/1.1 connection Pool. |
pool-request | pool-request = fn [mut pool Pool, method str, target_url str, body bytes, opts RequestOpts] HttpResponse | Executes a pooled HTTP/1.1 request reusing or establishing a persistent keep-alive stream. |
pool-get | pool-get = fn [mut pool Pool, target_url str, opts RequestOpts] HttpResponse | Performs a pooled HTTP GET request. |
close-pool | close-pool = fn [mut pool Pool] | Closes all idle keep-alive sockets in pool. |
Verified Doctest (net/client/basic-header)
VEKO
use [hc = net/client]
h = hc/basic-header 'alice' 'secret'
if (map/get h 'Authorization') != 'Basic YWxpY2U6c2VjcmV0' [ err 'basic auth' ] else [ .ok ]Module net/dns
Exported Structs & Interfaces
Record:Record = struct { name str, rtype i64, ttl i64, value str, rdata bytes }— Decoded DNS resource record.Response:Response = struct { id i64, rcode i64, answers block }— Decoded DNS response message.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
TYPE-A | TYPE-A = fn [] i64 | DNS record type constants (RFC 1035 / RFC 3596 / RFC 2782). |
TYPE-NS | TYPE-NS = fn [] i64 | Exported net/dns/TYPE-NS operation. |
TYPE-CNAME | TYPE-CNAME = fn [] i64 | Exported net/dns/TYPE-CNAME operation. |
TYPE-TXT | TYPE-TXT = fn [] i64 | Exported net/dns/TYPE-TXT operation. |
TYPE-AAAA | TYPE-AAAA = fn [] i64 | Exported net/dns/TYPE-AAAA operation. |
TYPE-SRV | TYPE-SRV = fn [] i64 | Exported net/dns/TYPE-SRV operation. |
encode-query | encode-query = fn [tx_id i64, domain str, qtype i64] bytes | Encodes an RFC 1035 standard recursive DNS query packet for domain and qtype (e.g. dns/TYPE-A). |
decode-response | decode-response = fn [msg bytes] Response | Decodes an RFC 1035 DNS response packet msg into a Response containing parsed Record answers. |
parse-hosts | parse-hosts = fn [text str] map[block] | Parses /etc/hosts formatted text into a map[block] mapping lowercased hostnames to IP lists. |
parse-resolv-conf | parse-resolv-conf = fn [text str] block | Parses /etc/resolv.conf text and returns a block of IPv4 nameserver addresses. |
query-udp | query-udp = fn [nameserver str, port i64, domain str, qtype i64, timeout dur] Response | Sends a single UDP DNS query for domain (qtype) to nameserver:port with timeout and decodes the Response. |
resolve-host | resolve-host = fn [host str] block | Resolves host to IPv4 addresses via numeric check, /etc/hosts, OS net/resolve, or /etc/resolv.conf UDP DNS. |
Verified Doctest (net/dns/encode-query)
VEKO
use [dns = net/dns]
pkt = dns/encode-query 0x1234 'example.com' (dns/TYPE-A)
if (len pkt) < 25 or (bytes/get-u16-be pkt 0) != 0x1234 [ err 'dns encode-query' ] else [ .ok ]Module net/http2
Exported Structs & Interfaces
Message:Message = struct { stream_id i64, status i64 = ..., method str = ..., path str = ..., headers map[str] = ..., body bytes, has_stream bool = ..., stream any = ... }— HTTP/2 request/response message exchanged over anH2Connstream.H2ServerOpts:H2ServerOpts = struct { max_requests i64 = ..., max_concurrent_streams i64 = ..., max_frame_size i64 = ..., max_header_bytes i64 = ..., max_continuation_cnt i64 = ..., max_hpack_table_size i64 = ..., max_body_bytes i64 = ..., max_rst_budget i64 = ..., max_ctrl_budget i64 = ... }— Server limits & DoS/flood mitigations forserve-conn-opts.H2Conn:H2Conn = struct { stream io/Stream, next_stream_id i64 = ..., is_server bool = ... }— Active HTTP/2 connection wrapping anio/Stream(plain TCP, TLS 1.3 ALPN'h2', orio/mem-stream).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
write-frame | write-frame = fn [mut conn H2Conn, f h2/Frame] i64 | Writes a single codec/http2 Frame onto conn. |
read-frame-max | read-frame-max = fn [mut conn H2Conn, max_frame_size i64] h2/Frame | Reads the next codec/http2 Frame from conn enforcing max_frame_size. |
read-frame | read-frame = fn [mut conn H2Conn] h2/Frame | Reads the next codec/http2 Frame from conn (default 16 MiB wire max). |
encode-rst-stream | encode-rst-stream = fn [err_code i64] bytes | Encodes a 4-byte RST_STREAM payload (error_code u32 BE). |
encode-goaway | encode-goaway = fn [last_sid i64, err_code i64] bytes | Encodes an 8-byte GOAWAY payload (last_stream_id u31 BE || error_code u32 BE). |
send-goaway | send-goaway = fn [mut conn H2Conn, last_sid i64, err_code i64] i64 | Sends a GOAWAY frame on stream 0. |
send-rst-stream | send-rst-stream = fn [mut conn H2Conn, stream_id i64, err_code i64] i64 | Sends a RST_STREAM frame on stream_id. |
client-open | client-open = fn [mut s io/Stream] H2Conn | Initializes an HTTP/2 client connection over s: sends the RFC 9113 preface and initial SETTINGS frame. |
server-accept | server-accept = fn [mut s io/Stream] H2Conn | Initializes an HTTP/2 server connection over s: verifies the client preface and sends server SETTINGS + ACK. |
request | request = fn [mut conn H2Conn, method str, path str, authority str, headers map[str], body bytes] Message | Sends an HTTP/2 request (HEADERS + optional DATA) and reads the server's Message response. |
read-request | read-request = fn [mut conn H2Conn] Message | Reads the next complete HTTP/2 request Message on a server H2Conn. |
write-response | write-response = fn [mut conn H2Conn, stream_id i64, status i64, headers map[str], body bytes] i64 | Writes an HTTP/2 server response (HEADERS + optional DATA with END_STREAM) on stream_id. |
encode-window-update | encode-window-update = fn [inc i64] bytes | Exported net/http2/encode-window-update operation. |
serve-conn-opts | serve-conn-opts = fn [mut s io/Stream, handler any, opts H2ServerOpts] i64 | Serves an RFC 9113 HTTP/2 connection over s with explicit H2ServerOpts DoS & flood limits (concurrent stream cap, CONTINUATION flood guard, HPACK table cap, and CVE-2023-44487 Rapid Reset GOAWAY). |
serve-conn | serve-conn = fn [mut s io/Stream, handler any, max_requests i64] i64 | Serves an RFC 9113 HTTP/2 connection over s using default H2ServerOpts. handler is fn [req Message] Message. Pass max_requests <= 0 for unlimited streams on the connection. |
Verified Doctest (net/http2/request)
VEKO
use [io, h2 = net/http2, ch2 = codec/http2]
mut wire = io/mem-stream (bytes/with-cap 0)
mut cc = h2/client-open mut wire
hblk = ch2/hpack-encode [(ch2/Header { name = ':method', value = 'GET' }) (ch2/Header { name = ':path', value = '/ping' })]
_ = h2/write-frame mut cc (ch2/Frame { ftype = 1, flags = 5, stream_id = 1, payload = hblk })
mut rx = io/mem-stream (io/read-all mut cc.stream)
mut sc = h2/server-accept mut rx
req = h2/read-request mut sc
if req.method != 'GET' or req.path != '/ping' or req.stream_id != 1 [ err 'net/http2' ] else [ .ok ]Module net/http3
Exported Structs & Interfaces
Message:Message = struct { stream_id i64, status i64 = ..., method str = ..., path str = ..., headers map[str] = ..., body bytes }— HTTP/3 request/response message exchanged over a QUIC stream.ReassemblyBuf:ReassemblyBuf = struct { data bytes, ranges block, fin_known bool = ..., final_size i64 = ... }— Tracks out-of-order byte intervals without corrupting unreceived prefixes with zero bytes.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
derive-quic-keys | derive-quic-keys = fn [secret bytes, cs i64] map | Exported net/http3/derive-quic-keys operation. |
derive-initial-keys | derive-initial-keys = fn [client_dcid bytes] map | Derives Initial client & server QUIC v1 keysets from the client's Initial Destination Connection ID (dcid). |
seal-long-packet | seal-long-packet = fn [ptype i64, dcid bytes, scid bytes, pn i64, ks map, raw_frames bytes, pad_to i64] bytes | Seals a Long Header QUIC v1 packet (ptype: 0 = Initial, 2 = Handshake) with 2-byte packet number. |
seal-short-packet | seal-short-packet = fn [dcid bytes, pn i64, ks map, raw_frames bytes] bytes | Seals a Short Header (1-RTT) QUIC v1 packet with 2-byte packet number. |
reconstruct-pn | reconstruct-pn = fn [largest_pn i64, truncated_pn i64, pn_nbits i64] i64 | RFC 9000 Appendix A.3 packet number reconstruction from wire-truncated truncated_pn (pn_nbits in 8, 16, 24, 32). |
open-long-packet-pn | open-long-packet-pn = fn [dgram bytes, off i64, ks map, largest_pn i64] any | Parses & unprotects one Long Header packet at off inside UDP dgram, reconstructing full 62-bit PN from largest_pn. |
open-long-packet | open-long-packet = fn [dgram bytes, off i64, ks map] any | Parses & unprotects one Long Header packet at off inside UDP dgram. |
open-short-packet-pn | open-short-packet-pn = fn [dgram bytes, off i64, local_cid_len i64, ks map, largest_pn i64] any | Parses & unprotects a Short Header (1-RTT) packet from off to the end of dgram, reconstructing PN from largest_pn. |
open-short-packet | open-short-packet = fn [dgram bytes, off i64, local_cid_len i64, ks map] any | Parses & unprotects a Short Header (1-RTT) packet from off to the end of dgram. |
build-transport-params | build-transport-params = fn [orig_dcid bytes, init_scid bytes, is_server bool] bytes | Exported net/http3/build-transport-params operation. |
record-rx-pn | record-rx-pn = fn [ranges block, pn i64] block | Merges received packet number pn into sorted ascending disjoint [lo, hi] inclusive intervals (retaining latest 16 ranges). |
encode-ack-ranges | encode-ack-ranges = fn [ranges block] bytes | Encodes an RFC 9000 §19.3 ACK frame from ascending disjoint [lo, hi] inclusive PN intervals. |
encode-ack-frame | encode-ack-frame = fn [largest_pn i64] bytes | Exported net/http3/encode-ack-frame operation. |
encode-crypto-frame | encode-crypto-frame = fn [offset i64, data bytes] bytes | Exported net/http3/encode-crypto-frame operation. |
encode-stream-frame | encode-stream-frame = fn [stream_id i64, offset i64, data bytes, fin bool] bytes | Exported net/http3/encode-stream-frame operation. |
parse-quic-frames | parse-quic-frames = fn [buf bytes] any | Parses all QUIC frames inside a decrypted packet payload into a block of frame maps. |
encode-h3-response-stream | encode-h3-response-stream = fn [resp Message] bytes | Encodes HTTP/3 response headers + body into a contiguous HTTP/3 stream byte buffer (HEADERS + optional DATA). |
decode-h3-request-stream | decode-h3-request-stream = fn [stream_id i64, wire bytes] any | Decodes an HTTP/3 request stream buffer (HEADERS + optional DATA frames) into a Message. |
new-reasm | new-reasm = fn [] ReassemblyBuf | Creates an empty ReassemblyBuf. |
reasm-insert | reasm-insert = fn [mut rb ReassemblyBuf, offset i64, chunk bytes, is_fin bool, max_bytes i64] bool | Inserts chunk at offset into rb (rejecting offsets exceeding max_bytes), merging contiguous [lo, hi] intervals. |
reasm-contiguous-len | reasm-contiguous-len = fn [rb ReassemblyBuf] i64 | Returns the contiguous number of bytes received starting strictly at offset 0. |
reasm-complete? | reasm-complete? = fn [rb ReassemblyBuf] bool | Returns true iff FIN has arrived and all bytes [0..final_size] are contiguously present. |
serve-udp | serve-udp = fn [sock i64, get_ident_fn any, handler any, max_requests i64] i64 | Serves HTTP/3 over QUIC v1 on bound UDP socket sock (net/udp-bind) with contiguous interval reassembly, multi-packet PQC Initial handshakes, RFC 9000 PN reconstruction, multi-range ACKs, cwnd, and 25ms PTO retransmission. |
request | request = fn [host str, port i64, method str, path str, headers map[str], body bytes] any | Performs a complete pure-Veko HTTP/3 over QUIC v1 request (Initial ClientHello -> Handshake Finished -> 1-RTT QPACK HEADERS/DATA -> Message response). Supports WAN DNS resolution, '0.0.0.0' socket binding, out-of-order ReassemblyBuf, RFC 9000 PN reconstruction, multi-range ACKs, and 25ms PTO retransmission. |
Verified Doctest (net/http3/derive-initial-keys)
VEKO
use [h3 = net/http3, hex = codec/hex]
dcid = hex/decode '8394c8f03e515708'
init = h3/derive-initial-keys dcid
if (hex/encode init.client.key) != '1f369613dd76d5467730efcbe3b1a22d' or (len init.client.key) != 16 [
err 'quic initial key len'
] else [ .ok ]Module net/ip
Exported Structs & Interfaces
IpAddr:IpAddr = struct { version i64, octets bytes }— Parsed IPv4 (version = 4, 4 octets) or IPv6 (version = 6, 16 octets) address.Cidr:Cidr = struct { addr IpAddr, prefix_len i64 }— Parsed CIDR network prefix (addr/prefix_len, e.g.10.0.0.0/8orfc00::/7).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
parse | parse = fn [s str] IpAddr | Parses an IPv4 or IPv6 address string into an IpAddr. |
format | format = fn [a IpAddr] str | Formats an IpAddr into its canonical string representation (RFC 5952 compression for IPv6). |
v4? | v4? = fn [a IpAddr] bool | Exported net/ip/v4? operation. |
v6? | v6? = fn [a IpAddr] bool | Exported net/ip/v6? operation. |
loopback? | loopback? = fn [a IpAddr] bool | Returns true if a is a loopback address (127.0.0.0/8 or ::1). |
private? | private? = fn [a IpAddr] bool | Returns true if a is an RFC 1918 / link-local / ULA private address. |
parse-cidr | parse-cidr = fn [s str] Cidr | Parses a CIDR prefix string ('10.0.0.0/8' or '2001:db8::/32'). |
contains? | contains? = fn [cidr Cidr, target IpAddr] bool | Returns true if cidr contains target. |
Verified Doctest (net/ip/parse)
VEKO
use [ip = net/ip]
a = ip/parse '192.168.1.10'
b = ip/parse '2001:db8::1'
if (not (ip/v4? a)) or (not (ip/private? a)) or (not (ip/v6? b)) [ err 'ip parse' ] else [ .ok ]Module net/tls13
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
build-client-hello-ext | build-client-hello-ext = fn [sni str, eph_pub bytes, mlkem_ek bytes, rnd bytes, sess_id bytes, alpn str] bytes | Builds an RFC 8446 ClientHello handshake payload supporting optional hybrid X25519MLKEM768 (0x11EC) PQC key share. |
build-client-hello | build-client-hello = fn [sni str, eph_pub bytes, rnd bytes, sess_id bytes, alpn str] bytes | Builds an RFC 8446 ClientHello handshake payload (without TLS record header). |
build-quic-client-hello | build-quic-client-hello = fn [sni str, eph_pub bytes, rnd bytes, quic_tp bytes] bytes | Builds an RFC 9001 QUIC-TLS ClientHello (legacy_session_id = empty, alpn = 'h3', 0x0039 = quic_tp). |
parse-quic-server-hello | parse-quic-server-hello = fn [msg bytes] any | Parses a QUIC-TLS ServerHello (legacy_session_id == empty), extracting cipher suite and extension-order-independent key_share. |
client-handshake | client-handshake = fn [sock i64, host str, opts map] any | Performs a full pure-Veko TLS 1.3 client handshake over an already-connected TCP socket sock. opts supports server_name, alpn, pqc (enables hybrid X25519MLKEM768 0x11EC), roots_pem, roots_der, pins_sha256, insecure_skip_verify. |
connect | connect = fn [host str, port i64, opts map] any | Connects TCP (resolving DNS hostnames) + performs full pure-Veko TLS 1.3 handshake (opts: roots_pem, pins_sha256, alpn, server_name, timeout). |
send | send = fn [mut conn map, data bytes] any | Sends plaintext application data encrypted as TLS 1.3 ApplicationData records. |
recv | recv = fn [mut conn map] any | Receives decrypted application data (skips post-handshake NewSessionTicket records cleanly). |
close | close = fn [mut conn map] | Sends encrypted close_notify alert and closes underlying TCP socket. |
https-request | https-request = fn [host str, port i64, method str, target str, headers map, body bytes, opts map] any | Exported net/tls13/https-request operation. |
parse-pem-identity | parse-pem-identity = fn [fullchain_pem str, privkey_pem str] any | Parses PEM certificate chain (fullchain_pem) and private key (privkey_pem: Ed25519, ECDSA P-256, or RSA). Returns { chain_ders, key_info = { kind, priv, n, d } }. |
load-pem-identity | load-pem-identity = fn [cert_path str, key_path str] any | Loads a TLS 1.3 PEM identity from cert_path and key_path on disk. |
ensure-dev-p256-identity | ensure-dev-p256-identity = fn [cert_path str, key_path str, domain str] any | Ensures a bootstrap ECDSA P-256 certificate & PKCS#8 key exist at cert_path and key_path (generating them in pure Veko if absent). |
new-cert-reloader | new-cert-reloader = fn [cert_path str, key_path str] any | Creates a zero-downtime CertReloader tracking file mtime changes on cert_path and key_path. |
get-identity | get-identity = fn [mut rel map] any | Returns the active TLS identity, reloading automatically if either PEM file's mtime changed on disk. |
build-server-flight | build-server-flight = fn [ch_msg bytes, ident map, srv_alpns block, srv_quic_tp bytes, is_quic bool] any | Pure-bytes TLS 1.3 / QUIC-TLS server flight builder (shared by server-handshake-identity and net/http3). |
verify-client-finished | verify-client-finished = fn [c_hs_sec bytes, th_srv_fin bytes, cfin_msg bytes] bool | Verifies a TLS 1.3 / QUIC-TLS client Finished handshake message (0x14 || u24(hlen) || verify_data). |
server-handshake-identity-opts | server-handshake-identity-opts = fn [sock i64, ident map, srv_alpns block, hs_timeout dur, idle_timeout dur] any | Performs a browser-grade RFC 8446 TLS 1.3 server handshake with an enforced wall-clock deadline (hs_timeout, e.g. 5s). |
server-handshake-identity | server-handshake-identity = fn [sock i64, ident map, srv_alpns block] any | Performs a browser-grade RFC 8446 TLS 1.3 server handshake using ident (parse-pem-identity: ECDSA P-256, RSA-PSS, or Ed25519) and negotiates srv_alpns (e.g. ['h2' 'http/1.1']) plus AES-128-GCM or CHACHA20-POLY1305 and optional X25519MLKEM768. |
server-handshake | server-handshake = fn [sock i64, chain_ders block, leaf_seed bytes] any | Performs a minimal pure-Veko RFC 8446 server handshake on accepted socket sock using Ed25519 leaf keypair. Automatically negotiates hybrid X25519MLKEM768 (0x11EC) and ALPN ('h2' / 'http/1.1') when offered by client. Returns a connection handle compatible with tls13/send, tls13/recv, tls13/close, and tls13/tls-stream. |
tls-stream | tls-stream = fn [conn map] io/Stream | Wraps an established TLS 1.3 connection (connect or server-handshake) as an ORO io/Stream. |
Module net/websocket
Exported Structs & Interfaces
Frame:Frame = struct { fin bool = ..., opcode i64, masked bool = ..., payload bytes }— Decoded WebSocket frame.FrameTry:FrameTry = struct { complete bool, consumed i64, frame Frame }— Result of incremental non-blocking WebSocket frame parsing (try-decode-frame).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
OP-CONT | OP-CONT = fn [] i64 | WebSocket opcodes (RFC 6455 Section 5.2). |
OP-TEXT | OP-TEXT = fn [] i64 | Exported net/websocket/OP-TEXT operation. |
OP-BINARY | OP-BINARY = fn [] i64 | Exported net/websocket/OP-BINARY operation. |
OP-CLOSE | OP-CLOSE = fn [] i64 | Exported net/websocket/OP-CLOSE operation. |
OP-PING | OP-PING = fn [] i64 | Exported net/websocket/OP-PING operation. |
OP-PONG | OP-PONG = fn [] i64 | Exported net/websocket/OP-PONG operation. |
accept-key | accept-key = fn [client_key str] str | Computes the RFC 6455 Sec-WebSocket-Accept header value from client_key. |
encode-frame | encode-frame = fn [f Frame, mask_key bytes] bytes | Encodes a WebSocket Frame into RFC 6455 wire bytes (applying 4-byte XOR mask_key when f.masked == true). |
decode-frame | decode-frame = fn [wire bytes] Frame | Decodes a single RFC 6455 WebSocket Frame from wire bytes (unmasking payload automatically). |
write-frame | write-frame = fn [mut s io/Stream, f Frame] i64 | Writes a WebSocket Frame onto io/Stream s (generating fresh CSPRNG mask when f.masked == true). |
read-frame | read-frame = fn [mut s io/Stream] Frame | Reads the next RFC 6455 WebSocket Frame from io/Stream s. |
client-handshake | client-handshake = fn [mut s io/Stream, host str, path str] enum | Performs an RFC 6455 client HTTP/1.1 WebSocket Upgrade handshake over io/Stream s. |
server-handshake | server-handshake = fn [mut s io/Stream] str | Performs an RFC 6455 server HTTP/1.1 WebSocket Upgrade handshake over io/Stream s and returns the request path. |
try-decode-frame | try-decode-frame = fn [raw bytes] FrameTry | Incrementally decodes one RFC 6455 frame from a non-blocking receive buffer raw. Returns FrameTry { complete = false, consumed = 0, ... } if more bytes are needed. |
Verified Doctest (net/websocket/accept-key)
VEKO
use [ws = net/websocket]
acc = ws/accept-key 'dGhlIHNhbXBsZSBub25jZQ=='
if acc != 's3pPLMBiTxaQ9kYGzzhZRbK+xOo=' [ err 'ws accept-key' ] else [ .ok ]Module otel
Exported Structs & Interfaces
TraceContext:TraceContext = struct { trace_id str, span_id str, sampled bool = ... }— W3Ctraceparentcontext (00-<trace_id_32hex>-<span_id_16hex>-<flags_2hex>).Span:Span = struct { name str, trace_id str, span_id str, parent_id str, start_ns i64, end_ns i64 = ..., status str = ..., attributes map[str] = ... }— Recorded distributed trace span.Registry:Registry = struct { service_name str, counters map[i64], gauges map[i64], helps map[str] }— In-memory metrics registry supporting counters and gauges.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
make-context | make-context = fn [trace_hi i64, trace_lo i64, span_num i64, sampled bool] TraceContext | Formats a TraceContext as a W3C traceparent HTTP header value. |
format-traceparent | format-traceparent = fn [ctx TraceContext] str | Serializes ctx into 00-<32hex>-<16hex>-<01|00>. |
parse-traceparent | parse-traceparent = fn [header_val str] TraceContext | Parses and validates a W3C traceparent header string (returns err if malformed; combine with /or). |
start-span | start-span = fn [name str, parent TraceContext, span_num i64, start_ns i64] Span | Starts a child Span linked to parent with explicit start_ns timestamp and span_num ID. |
set-attr | set-attr = fn [mut sp Span, key str, val str] | Sets a string attribute on sp. |
finish-span | finish-span = fn [mut sp Span, end_ns i64, /status st str] Span | Completes sp with end_ns and status ('OK' or 'ERROR'). |
export-otlp-json | export-otlp-json = fn [service_name str, spans block[Span]] str | Exports a block[Span] as an OpenTelemetry OTLP/HTTP ExportTraceServiceRequest JSON payload. |
new-registry | new-registry = fn [service_name str] Registry | Creates a new metrics Registry for service_name. |
inc-counter | inc-counter = fn [mut reg Registry, name str, delta i64, /help help_txt str] i64 | Increments monotonic counter name by delta (delta >= 0). |
set-gauge | set-gauge = fn [mut reg Registry, name str, val i64, /help help_txt str] i64 | Sets instantaneous gauge name to val. |
export-prometheus | export-prometheus = fn [reg Registry] str | Renders all counters and gauges in Prometheus 0.0.4 text exposition format. |
Verified Doctest (otel/make-context)
VEKO
use [otel]
ctx = otel/make-context 0x1122334455667788 0x99aabbccddeeff00 0x0102030405060708 true
hdr = otel/format-traceparent ctx
parsed = otel/parse-traceparent hdr
if parsed.trace_id != ctx.trace_id or parsed.span_id != ctx.span_id or (not parsed.sampled) [
err 'traceparent roundtrip'
] else [ .ok ]Module profile/flamegraph
Exported Structs & Interfaces
StackSample:StackSample = struct { stack block[str], weight i64 }— One folded call-stack sample (stackordered root -> leaf,weightin nanoseconds or sample ticks).FnStat:FnStat = struct { name str, calls i64, self_ns i64, incl_ns i64 }— Per-function hotspot summary row.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
format-ns | format-ns = fn [ns i64] str | Formats nanoseconds into a compact human-readable duration ('14.2 ms', '320 us', '850 ns'). |
parse-folded | parse-folded = fn [text str] block[StackSample] | Parses standard Brendan Gregg folded-stack lines ('main;parse;lex 4200\n...') into block[StackSample]. |
format-folded | format-folded = fn [samples block[StackSample]] str | Serializes samples into canonical folded-stack text ('a;b;c 123\n'). |
render-svg | render-svg = fn [title str, samples block[StackSample], /subtitle sub str, /width svg_w i64] str | Renders a self-contained, Light-Mode interactive SVG flamegraph (click to zoom, hover for inclusive/self stats, live search bar). |
Verified Doctest (profile/flamegraph/parse-folded)
VEKO
use [fg = profile/flamegraph]
samples = fg/parse-folded 'main;parse;tokenize 400\nmain;emit 600\n'
svg = fg/render-svg 'Compiler Profile' samples
if (len samples) != 2 or not (str/contains? svg '<svg') [ err 'flamegraph failed' ] else [ .ok ]Module reactor
Exported Structs & Interfaces
IoEvent:IoEvent = struct { token i64, mask i64 }— One readiness notification delivered bypoll.FdEntry:FdEntry = struct { fd i64, token i64, events i64, cb any }— Registered file descriptor entry tracked by aReactor.TimerEntry:TimerEntry = struct { id i64, fire_at_ns i64, interval_ns i64, active bool, cb any }— Scheduled timer entry tracked by aReactor.Reactor:Reactor = struct { poller i64, next_token i64 = ..., next_timer i64 = ..., stopped bool = ..., fds map = ..., timers block[TimerEntry] = ..., max_tick dur = ... }— Single-threaded readiness event loop with O(1) kernel readiness + timers + thread-safe waker.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
EV-READ | EV-READ = fn [] i64 | Readiness event mask flags. |
EV-WRITE | EV-WRITE = fn [] i64 | Exported reactor/EV-WRITE operation. |
EV-ERR | EV-ERR = fn [] i64 | Exported reactor/EV-ERR operation. |
EV-HUP | EV-HUP = fn [] i64 | Exported reactor/EV-HUP operation. |
EV-RW | EV-RW = fn [] i64 | Exported reactor/EV-RW operation. |
CTL-ADD | CTL-ADD = fn [] i64 | Poller control operations. |
CTL-MOD | CTL-MOD = fn [] i64 | Exported reactor/CTL-MOD operation. |
CTL-DEL | CTL-DEL = fn [] i64 | Exported reactor/CTL-DEL operation. |
readable? | readable? = fn [ev IoEvent] bool | Returns true if ev.mask indicates readability (EV-READ). |
writable? | writable? = fn [ev IoEvent] bool | Returns true if ev.mask indicates writability (EV-WRITE). |
errored? | errored? = fn [ev IoEvent] bool | Returns true if ev.mask indicates a socket error (EV-ERR). |
closed? | closed? = fn [ev IoEvent] bool | Returns true if ev.mask indicates peer hangup/EOF (EV-HUP). |
new | new = fn [] Reactor | Creates a new OS-backed readiness Reactor. |
waker | waker = fn [r Reactor] i64 | Returns a copyable i64 waker handle that can be passed to spawn workers for wake-handle. |
wake-handle | wake-handle = fn [poller_handle i64] enum | Thread-safe wakeup of a Reactor blocked in poll or tick using its waker handle. |
wake | wake = fn [r Reactor] enum | Wakes r if blocked in poll or tick. |
send-wake | send-wake = fn [ch any, msg any, waker_handle i64] enum | Sends msg onto channel ch and immediately wakes the target reactor via waker_handle so background spawn workers wake an OS epoll/kqueue/IOCP event loop in one call. |
register-cb | register-cb = fn [mut r Reactor, fd i64, events i64, cb any] i64 | Registers fd with readiness events mask (EV-READ, EV-WRITE, EV-RW) and optional callback cb (.ok for pull mode). Returns the assigned i64 token. |
register | register = fn [mut r Reactor, fd i64, events i64] i64 | Registers fd for pull-mode event delivery (no callback). Returns the assigned i64 token. |
modify | modify = fn [mut r Reactor, token i64, events i64] enum | Updates the readiness interest mask for a registered token. |
unregister | unregister = fn [mut r Reactor, token i64] enum | Unregisters token from the OS poller and removes it from r. |
token-fd | token-fd = fn [r Reactor, token i64] i64 | Returns the registered OS socket fd for token, or -1 if not found. |
after-cb | after-cb = fn [mut r Reactor, delay dur, cb any] i64 | Schedules a one-shot timer firing after delay with optional callback cb (.ok for pull mode). Returns the assigned timer_id. |
after | after = fn [mut r Reactor, delay dur] i64 | Schedules a pull-mode one-shot timer firing after delay. Returns timer_id. |
every-cb | every-cb = fn [mut r Reactor, interval dur, cb any] i64 | Schedules a repeating timer firing every interval with optional callback cb. Returns timer_id. |
every | every = fn [mut r Reactor, interval dur] i64 | Schedules a pull-mode repeating timer firing every interval. Returns timer_id. |
cancel-timer | cancel-timer = fn [mut r Reactor, timer_id i64] enum | Cancels timer timer_id (idempotent). |
next-wait | next-wait = fn [r Reactor, max_wait dur] dur | Computes the effective wait duration bounded by max_wait and the earliest active timer deadline. |
poll | poll = fn [mut r Reactor, timeout dur] block[IoEvent] | Polls the OS reactor for ready I/O events up to timeout (automatically capped by pending timers). Returns a block[IoEvent] of ready notifications. |
due-timers | due-timers = fn [mut r Reactor] block[i64] | Pull-mode timer drain: returns block[i64] of due timer IDs without invoking callbacks. |
tick | tick = fn [mut r Reactor, timeout dur] i64 | Runs one callback-mode reactor iteration: polls I/O up to timeout, invokes FD callbacks and due timer callbacks. Returns total number of events + timers dispatched. |
stop | stop = fn [mut r Reactor] enum | Requests that run stop after the current iteration and wakes the poller. |
run | run = fn [mut r Reactor, max_iters i64] i64 | Runs the callback-mode event loop until stop is called (or max_iters > 0 iterations elapse). |
close | close = fn [mut r Reactor] enum | Closes the underlying OS poller and releases all reactor resources (idempotent). |
Verified Doctest (reactor/readable?)
VEKO
use [reactor]
ev = reactor/IoEvent { token = 7, mask = (reactor/EV-READ) | (reactor/EV-HUP) }
if (not (reactor/readable? ev)) or (not (reactor/closed? ev)) or (reactor/writable? ev) [ err 'mask' ] else [ .ok ]Module tui
Exported Structs & Interfaces
Cell:Cell = struct { ch str = ..., fg i64 = ..., bg i64 = ..., style i64 = ... }— One character cell in a double-buffered terminalScreen.Screen:Screen = struct { width i64, height i64, cells block[Cell], prev block[Cell], dirty bool = ... }— Double-buffered terminal framebuffer with front (cells) and committed (prev) grids.KeyEvent:KeyEvent = struct { kind enum = ..., ch str = ..., ctrl bool = ..., alt bool = ... }— Decoded keyboard input event returned byparse-key.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
STYLE-NONE | STYLE-NONE = fn [] i64 | Style bitmask flags for Cell.style. |
STYLE-BOLD | STYLE-BOLD = fn [] i64 | Exported tui/STYLE-BOLD operation. |
STYLE-DIM | STYLE-DIM = fn [] i64 | Exported tui/STYLE-DIM operation. |
STYLE-UNDERLINE | STYLE-UNDERLINE = fn [] i64 | Exported tui/STYLE-UNDERLINE operation. |
STYLE-REVERSE | STYLE-REVERSE = fn [] i64 | Exported tui/STYLE-REVERSE operation. |
COLOR-DEFAULT | COLOR-DEFAULT = fn [] i64 | Default terminal color sentinel (-1). |
rgb | rgb = fn [r i64, g i64, b i64] i64 | Packs an 8-bit RGB triple into a 24-bit i64 color ((r << 16) | (g << 8) | b). |
color-white | color-white = fn [] i64 | Built-in high-contrast TrueColor palette helpers. |
color-slate | color-slate = fn [] i64 | Exported tui/color-slate operation. |
color-surface | color-surface = fn [] i64 | Exported tui/color-surface operation. |
color-cyan | color-cyan = fn [] i64 | Exported tui/color-cyan operation. |
color-emerald | color-emerald = fn [] i64 | Exported tui/color-emerald operation. |
color-amber | color-amber = fn [] i64 | Exported tui/color-amber operation. |
color-rose | color-rose = fn [] i64 | Exported tui/color-rose operation. |
esc | esc = fn [] str | Returns the ASCII ESC byte (0x1b) as a single-byte string. |
csi | csi = fn [suffix str] str | Returns an ANSI CSI sequence (ESC [ + suffix). |
clear-screen | clear-screen = fn [] str | Terminal screen & cursor control escape sequences. |
alt-screen-on | alt-screen-on = fn [] str | Exported tui/alt-screen-on operation. |
alt-screen-off | alt-screen-off = fn [] str | Exported tui/alt-screen-off operation. |
hide-cursor | hide-cursor = fn [] str | Exported tui/hide-cursor operation. |
show-cursor | show-cursor = fn [] str | Exported tui/show-cursor operation. |
reset-style | reset-style = fn [] str | Exported tui/reset-style operation. |
new-screen | new-screen = fn [w i64, h i64] Screen | Allocates a new w x h double-buffered Screen initialized to blank spaces. |
clear | clear = fn [mut s Screen, fg i64, bg i64] | Clears every cell on s to a space with foreground fg and background bg. |
set-cell | set-cell = fn [mut s Screen, x i64, y i64, ch str, fg i64, bg i64, style i64] | Sets one cell at (x, y) if within bounds. |
get-cell | get-cell = fn [s Screen, x i64, y i64] Cell | Reads the cell at (x, y), returning a blank cell if out of bounds. |
draw-text | draw-text = fn [mut s Screen, x i64, y i64, text str, fg i64, bg i64, style i64] | Draws a single-line string starting at (x, y), clipped to the screen width. |
fill-rect | fill-rect = fn [mut s Screen, x i64, y i64, w i64, h i64, ch str, fg i64, bg i64, style i64] | Fills a rectangle (x, y, w, h) with character ch. |
draw-box | draw-box = fn [mut s Screen, x i64, y i64, w i64, h i64, title str, border enum, fg i64, bg i64] | Draws a framed box with optional title. Supported border styles: .single, .double, .rounded, .ascii. |
draw-progress | draw-progress = fn [mut s Screen, x i64, y i64, w i64, pct i64, fill_fg i64, track_fg i64, bg i64] | Draws a horizontal progress bar of width w filled to pct (clamped 0..100). |
draw-sparkline | draw-sparkline = fn [mut s Screen, x i64, y i64, vals block, fg i64, bg i64] | Draws an inline sparkline across len vals columns using 8-level vertical bar glyphs. |
draw-table | draw-table = fn [mut s Screen, x i64, y i64, headers block, rows block, col_widths block, fg i64, hdr_fg i64, bg i64] | Draws a tabular grid with bold headers and fixed column widths. |
draw-menu | draw-menu = fn [mut s Screen, x i64, y i64, w i64, items block, selected i64, fg i64, sel_fg i64, sel_bg i64, bg i64] | Draws a selectable vertical menu list with highlight row selected. |
render-diff | render-diff = fn [mut s Screen] str | Renders only cells modified since the previous render-diff call into a minimal ANSI frame, then commits the front buffer into s.prev. Returns '' if nothing changed. |
render-plain | render-plain = fn [s Screen] str | Renders a clean multi-line plain-text snapshot of s (without ANSI codes) for logs and tests. |
parse-key | parse-key = fn [raw bytes] KeyEvent | Decodes an input byte slice from os/stdin into a structured KeyEvent. Handles ANSI CSI arrows, Home/End/PgUp/PgDn/Delete, Enter, Tab, Backspace, Esc, Ctrl-A..Z, and UTF-8 text. |
Verified Doctest (tui/rgb)
VEKO
use [tui]
c = tui/rgb 16 185 129
if c != 1096065 [ err 'rgb pack mismatch' ] else [ .ok ]Module ui/canvas
Exported Structs & Interfaces
Color:Color = struct { r i64, g i64, b i64, a i64 = ... }— 8-bit RGBA color value.Canvas:Canvas = struct { width i64, height i64, pixels bytes, clip_on bool = ..., clip_x i64 = ..., clip_y i64 = ..., clip_w i64 = ..., clip_h i64 = ... }— Offscreen RGBA32 pixel surface (width * height * 4bytes, top-down row-major) with optional clip rect.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
rgba | rgba = fn [r i64, g i64, b i64, a i64] Color | Constructs an RGBA Color with components clamped to 0..255. |
rgb | rgb = fn [r i64, g i64, b i64] Color | Constructs an opaque RGB Color (a = 255). |
color-bg-dark | color-bg-dark = fn [] Color | Built-in modern UI palette constructors. |
color-surface | color-surface = fn [] Color | Exported ui/canvas/color-surface operation. |
color-border | color-border = fn [] Color | Exported ui/canvas/color-border operation. |
color-text-primary | color-text-primary = fn [] Color | Exported ui/canvas/color-text-primary operation. |
color-text-muted | color-text-muted = fn [] Color | Exported ui/canvas/color-text-muted operation. |
color-cyan | color-cyan = fn [] Color | Exported ui/canvas/color-cyan operation. |
color-emerald | color-emerald = fn [] Color | Exported ui/canvas/color-emerald operation. |
color-amber | color-amber = fn [] Color | Exported ui/canvas/color-amber operation. |
color-rose | color-rose = fn [] Color | Exported ui/canvas/color-rose operation. |
set-clip | set-clip = fn [mut cv Canvas, x i64, y i64, w i64, h i64] | Sets an active clipping rectangle (x, y, w, h) on cv (clamped to canvas bounds). |
reset-clip | reset-clip = fn [mut cv Canvas] | Clears any active clipping rectangle on cv, restoring full-canvas drawing. |
new-canvas | new-canvas = fn [w i64, h i64] Canvas | Allocates a new w x h RGBA32 Canvas initialized to transparent black (0, 0, 0, 0). |
clear | clear = fn [mut cv Canvas, c Color] | Fills the entire canvas with c in place (zero per-frame heap allocation). |
get-pixel | get-pixel = fn [cv Canvas, x i64, y i64] Color | Reads the RGBA Color at (x, y) (returns transparent black if out of bounds). |
set-pixel | set-pixel = fn [mut cv Canvas, x i64, y i64, c Color] | Sets or Porter-Duff SRC_OVER alpha-blends pixel (x, y) with c (honoring any active clip rect). |
fill-rect | fill-rect = fn [mut cv Canvas, x i64, y i64, w i64, h i64, c Color] | Fills a clipped rectangle (x, y, w, h) with c (supports alpha blending and active clip rect). |
stroke-rect | stroke-rect = fn [mut cv Canvas, x i64, y i64, w i64, h i64, thickness i64, c Color] | Draws a rectangle outline of thickness pixels. |
fill-gradient-v | fill-gradient-v = fn [mut cv Canvas, x i64, y i64, w i64, h i64, top Color, bottom Color] | Fills a vertical linear gradient across (x, y, w, h) from top to bottom. |
fill-rounded-rect | fill-rounded-rect = fn [mut cv Canvas, x i64, y i64, w i64, h i64, radius i64, c Color] | Fills a rounded rectangle with corner radius. |
stroke-rounded-rect | stroke-rounded-rect = fn [mut cv Canvas, x i64, y i64, w i64, h i64, radius i64, c Color] | Draws a crisp 1px rounded rectangle border matching fill-rounded-rect. |
fill-circle | fill-circle = fn [mut cv Canvas, cx i64, cy i64, r i64, c Color] | Draws a filled circle centered at (cx, cy) with radius r. |
stroke-circle | stroke-circle = fn [mut cv Canvas, cx i64, cy i64, r i64, c Color] | Draws a 1px circle outline centered at (cx, cy) with radius r. |
draw-line-smooth | draw-line-smooth = fn [mut cv Canvas, x0 i64, y0 i64, x1 i64, y1 i64, c Color] | Draws an anti-aliased multi-pixel line from (x0, y0) to (x1, y1) with soft fringe. |
draw-line | draw-line = fn [mut cv Canvas, x0 i64, y0 i64, x1 i64, y1 i64, c Color] | Draws an integer Bresenham line from (x0, y0) to (x1, y1). |
draw-char | draw-char = fn [mut cv Canvas, x i64, y i64, ch i64, scale i64, c Color] | Draws a single 5x7 glyph scaled by scale at (x, y). |
measure-text-width | measure-text-width = fn [text str, scale i64] i64 | Measures the pixel width of text rendered at integer scale. |
draw-text | draw-text = fn [mut cv Canvas, x i64, y i64, text str, scale i64, c Color] | Draws ASCII text at (x, y) using the built-in 5x7 bitmap font scaled by scale. |
encode-bmp | encode-bmp = fn [cv Canvas] bytes | Encodes cv as an uncompressed 24-bit BMP image ('BM' header + bottom-up BGR rows). |
encode-ppm | encode-ppm = fn [cv Canvas] bytes | Encodes cv as a binary Netpbm PPM (P6) RGB24 image. |
Verified Doctest (ui/canvas/rgba)
VEKO
use [cv = ui/canvas]
c = cv/rgba 34 211 238 255
if c.r != 34 or c.g != 211 or c.b != 238 or c.a != 255 [ err 'rgba' ] else [ .ok ]Module ui/font
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
line-height | line-height = fn [size i64] i64 | Returns the vertical line height in pixels for font size (1 = 12px, 2 = 20px, 3 = 28px). |
measure-text | measure-text = fn [text str, size i64] i64 | Measures the pixel width of text rendered with proportional kerning at size. |
measure-mono | measure-mono = fn [text str, size i64] i64 | Measures fixed-width monospace text width at size. |
draw-text | draw-text = fn [mut c cv/Canvas, x i64, y i64, text str, size i64, col cv/Color] | Draws mixed-case proportional UI text at (x, y) at size (1 = 12px body, 2 = 18px heading, 3 = 27px display). |
draw-bold | draw-bold = fn [mut c cv/Canvas, x i64, y i64, text str, size i64, col cv/Color] | Draws semi-bold proportional UI text (ideal for card headers, active tabs, and primary badges). |
draw-mono | draw-mono = fn [mut c cv/Canvas, x i64, y i64, text str, size i64, col cv/Color] | Draws fixed-width mixed-case monospace text at (x, y) (ideal for code, numeric columns, and metrics). |
draw-truncated | draw-truncated = fn [mut c cv/Canvas, x i64, y i64, max_w i64, text str, size i64, col cv/Color] | Draws proportional text truncated with '...' if its pixel width exceeds max_w. |
draw-bullets | draw-bullets = fn [mut c cv/Canvas, x i64, y i64, count i64, size i64, col cv/Color] i64 | Draws count masked secret bullet dots at (x, y) without inspecting secret content. |
Verified Doctest (ui/font/measure-text)
VEKO
use [fnt = ui/font]
w1 = fnt/measure-text 'Veko UI' 1
w2 = fnt/measure-text 'Veko UI' 2
if w1 <= 20 or w2 != (w1 * 2) [ err 'measure-text' ] else [ .ok ]Module ui/layout
Exported Structs & Interfaces
Box:Box = struct { x i64, y i64, w i64, h i64 }— Axis-aligned integer layout rectangle.Track:Track = struct { kind i64, value i64 }— 1D flex/grid track specification (kind == 0fixed pixels;kind == 1proportional flex weight).Span:Span = struct { offset i64, length i64 }— Solved 1D[offset, length]span along an axis.ClipStack:ClipStack = struct { frames block[Box] }— Stack of nested clipping boxes for scrollable containers, split panes, and modals.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
px | px = fn [pixels i64] Track | Creates a fixed-pixel Track. |
flex | flex = fn [weight i64] Track | Creates a proportional flex-grow Track (weight >= 1). |
solve-tracks | solve-tracks = fn [origin i64, total_len i64, tracks block[Track], gap i64] block[Span] | Solves a 1D list of Tracks across [origin .. origin + total_len] with inter-track gap. |
pad-edges | pad-edges = fn [b Box, top i64, right i64, bottom i64, left i64] Box | Insets b by (top, right, bottom, left) padding. |
pad | pad = fn [b Box, p i64] Box | Uniformly insets b on all 4 sides by p pixels. |
flex-row | flex-row = fn [bounds Box, tracks block[Track], gap i64] block[Box] | Lays out horizontal columns inside bounds from tracks with gap. |
flex-col | flex-col = fn [bounds Box, tracks block[Track], gap i64] block[Box] | Lays out vertical rows inside bounds from tracks with gap. |
grid | grid = fn [bounds Box, rows i64, cols i64, row_gap i64, col_gap i64] block[Box] | Lays out a 2D rows x cols uniform grid inside bounds (row-major r * cols + c). |
split-h | split-h = fn [bounds Box, ratio_pct i64, divider_w i64] block[Box] | Splits bounds horizontally into [left_box, divider_box, right_box] at ratio_pct (10..90). |
split-v | split-v = fn [bounds Box, ratio_pct i64, divider_h i64] block[Box] | Splits bounds vertically into [top_box, divider_box, bottom_box] at ratio_pct (10..90). |
new-clip-stack | new-clip-stack = fn [] ClipStack | Creates an empty ClipStack. |
push-clip | push-clip = fn [mut cs ClipStack, mut c cv/Canvas, rect Box] | Pushes an intersected clip box onto cs and activates it on c. |
pop-clip | pop-clip = fn [mut cs ClipStack, mut c cv/Canvas] | Pops the top clip box from cs and restores the parent clip (or full canvas if empty). |
Verified Doctest (ui/layout/solve-tracks)
VEKO
use [lay = ui/layout]
spans = lay/solve-tracks 10 310 [(lay/px 100) (lay/flex 1) (lay/flex 1)] 5
if (len spans) != 3 or spans[0].length != 100 or spans[1].length != 100 or spans[2].offset != 220 [
err 'solve-tracks'
] else [ .ok ]Module ui/wayland
Exported Structs & Interfaces
WlMsgHdr:WlMsgHdr = struct { object_id i64, opcode i64, size i64 }— Decoded 8-byte Wayland wire message header.WlGlobal:WlGlobal = struct { name i64, interface str, version i64 }— Decodedwl_registry.globaladvertisement event (opcode 0).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
wl-display-id | wl-display-id = fn [] i64 | Exported ui/wayland/wl-display-id operation. |
shm-format-argb8888 | shm-format-argb8888 = fn [] i64 | Exported ui/wayland/shm-format-argb8888 operation. |
shm-format-xrgb8888 | shm-format-xrgb8888 = fn [] i64 | Exported ui/wayland/shm-format-xrgb8888 operation. |
socket-path | socket-path = fn [xdg_runtime_dir str, wayland_display str] str | Resolves the canonical AF_UNIX Wayland socket path from XDG_RUNTIME_DIR and WAYLAND_DISPLAY. |
encode-hdr | encode-hdr = fn [object_id i64, opcode i64, size i64] bytes | Encodes an 8-byte Wayland wire header (object_id, (size << 16) | opcode). |
decode-hdr | decode-hdr = fn [pkt bytes, off i64] WlMsgHdr | Decodes an 8-byte Wayland wire header at off inside pkt. |
push-str-arg | push-str-arg = fn [mut buf bytes, s str] i64 | Appends a Wayland NUL-terminated 32-bit padded string argument to buf and returns bytes written. |
encode-sync | encode-sync = fn [callback_id i64] bytes | Encodes wl_display@1.sync(callback_id) (opcode 0, 12 bytes). |
encode-get-registry | encode-get-registry = fn [registry_id i64] bytes | Encodes wl_display@1.get_registry(registry_id) (opcode 1, 12 bytes). |
encode-registry-bind | encode-registry-bind = fn [registry_id i64, global_name i64, iface str, version i64, new_id i64] bytes | Encodes wl_registry.bind(name, interface, version, new_id) (opcode 0, untyped new_id wire layout). |
parse-registry-global | parse-registry-global = fn [pkt bytes, body_off i64] WlGlobal | Parses a wl_registry.global event body starting at off (after the 8-byte header). |
encode-create-surface | encode-create-surface = fn [compositor_id i64, surface_id i64] bytes | Encodes wl_compositor.create_surface(surface_id) (opcode 0, 12 bytes). |
encode-shm-create-pool | encode-shm-create-pool = fn [shm_id i64, pool_id i64, byte_size i64] bytes | Encodes wl_shm.create_pool(pool_id, byte_size) (opcode 0, 16 bytes; fd passed via SCM_RIGHTS). |
encode-pool-create-buffer | encode-pool-create-buffer = fn [pool_id i64, buf_id i64, offset i64, w i64, h i64, stride i64, fmt i64] bytes | Encodes wl_shm_pool.create_buffer(buf_id, offset, w, h, stride, format) (opcode 0, 32 bytes). |
encode-get-xdg-surface | encode-get-xdg-surface = fn [wm_base_id i64, xdg_surf_id i64, wl_surf_id i64] bytes | Encodes xdg_wm_base.get_xdg_surface(xdg_surf_id, wl_surf_id) (opcode 2, 16 bytes). |
encode-xdg-pong | encode-xdg-pong = fn [wm_base_id i64, serial i64] bytes | Encodes xdg_wm_base.pong(serial) (opcode 3, 12 bytes). |
encode-get-toplevel | encode-get-toplevel = fn [xdg_surf_id i64, toplevel_id i64] bytes | Encodes xdg_surface.get_toplevel(toplevel_id) (opcode 1, 12 bytes). |
encode-ack-configure | encode-ack-configure = fn [xdg_surf_id i64, serial i64] bytes | Encodes xdg_surface.ack_configure(serial) (opcode 4, 12 bytes). |
encode-set-title | encode-set-title = fn [toplevel_id i64, title str] bytes | Encodes xdg_toplevel.set_title(title) (opcode 2). |
encode-surface-present | encode-surface-present = fn [surface_id i64, buf_id i64, w i64, h i64] bytes | Encodes pipelined wl_surface.attach(buf_id, 0, 0) + wl_surface.damage(0, 0, w, h) + wl_surface.commit() (52 bytes). |
Verified Doctest (ui/wayland/socket-path)
VEKO
use [wl = ui/wayland]
p1 = wl/socket-path '/run/user/1000' ''
p2 = wl/socket-path '/run/user/1000' 'wayland-1'
p3 = wl/socket-path '/run/user/1000' '/tmp/custom-wl-0'
if p1 != '/run/user/1000/wayland-0' or p2 != '/run/user/1000/wayland-1' or p3 != '/tmp/custom-wl-0' [
err 'bad wayland socket path'
] else [ .ok ]Module ui/widgets
Exported Structs & Interfaces
Rect:Rect = struct { x i64, y i64, w i64, h i64 }— Axis-aligned integer bounding box.Theme:Theme = struct { bg cv/Color, surface cv/Color, surface_hover cv/Color, border cv/Color, text cv/Color, muted cv/Color, accent cv/Color, accent_text cv/Color, success cv/Color, warning cv/Color, danger cv/Color }— Color theme palette for immediate-mode widgets.UiState:UiState = struct { mouse_x i64 = ..., mouse_y i64 = ..., mouse_down bool = ..., mouse_clicked bool = ..., mouse_rclicked bool = ..., wheel_dy i64 = ..., key_code i64 = ..., text_char i64 = ..., hot_id str = ..., active_id str = ..., focused_id str = ..., selected_id str = ..., open_popup_id str = ..., clipboard str = ..., clipboard_dirty bool = ..., dpi_scale i64 = ..., clip_stack block[Rect] = ..., key_mods i64 = ..., shift_down bool = ..., ctrl_down bool = ..., alt_down bool = ..., key_consumed bool = ..., focus_order block[str] = ..., next_focus_order block[str] = ..., focus_scope_prefix str = ... }— Per-frame pointer, wheel, keyboard, focus, popup, and clipboard state for immediate-mode widgets.SplitResult:SplitResult = struct { first Rect, second Rect, ratio_pct i64 }— Result returned bysplit-pane-statecarrying both paneRects and updated mouse-draggedratio_pct.EditorSnap:EditorSnap = struct { text str, cursor i64, anchor i64 }— Undo/redo history snapshot forEditorState.EditorState:EditorState = struct { text str = ..., cursor i64 = ..., sel_anchor i64 = ..., pref_col i64 = ..., scroll_line i64 = ..., scroll_col i64 = ..., undo_stack block[EditorSnap] = ..., redo_stack block[EditorSnap] = ..., tab_width i64 = ..., syntax_vk bool = ... }— Persistent state forcode-editor(multi-line cursor, selection, scroll, 64-step undo/redo, Veko syntax highlighting).CommandItem:CommandItem = struct { id str, label str, category str = ..., shortcut str = ... }— Action entry displayed incommand-palette.PaletteState:PaletteState = struct { open bool = ..., query str = ..., selected i64 = ..., scroll i64 = ... }— Persistent state forcommand-palette.FileEntry:FileEntry = struct { name str, is_dir bool = ..., size i64 = ... }— Pure-data directory or file entry displayed infile-picker.FilePickerState:FilePickerState = struct { open bool = ..., dir str = ..., filename str = ..., ext_filter str = ..., filter_on bool = ..., selected i64 = ..., scroll_y i64 = ... }— Persistent state forfile-picker.FilePickerResult:FilePickerResult = struct { action enum, path str = ... }— Result returned each frame byfile-picker(actionin.none,.selected,.cancelled,.chdir).TreeNode:TreeNode = struct { id str, label str, depth i64 = ..., expanded bool = ..., has_children bool = ..., badge str = ... }— Hierarchical node descriptor fortree-view.ModalResult:ModalResult = struct { card Rect, body Rect, closed bool }— Result returned bymodalcarrying the outer dialog card, inner contentRect, and close-button hit state.ChartSeries:ChartSeries = struct { name str, values block, color cv/Color }— Multi-series data descriptor forline-chart.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
MOD-SHIFT | MOD-SHIFT = fn [] i64 | Keyboard modifier & virtual key constants (mirroring ui/MOD-* and ui/KEY-* with zero .ui capability). |
MOD-CTRL | MOD-CTRL = fn [] i64 | Exported ui/widgets/MOD-CTRL operation. |
MOD-ALT | MOD-ALT = fn [] i64 | Exported ui/widgets/MOD-ALT operation. |
KEY-BACKSPACE | KEY-BACKSPACE = fn [] i64 | Exported ui/widgets/KEY-BACKSPACE operation. |
KEY-TAB | KEY-TAB = fn [] i64 | Exported ui/widgets/KEY-TAB operation. |
KEY-ENTER | KEY-ENTER = fn [] i64 | Exported ui/widgets/KEY-ENTER operation. |
KEY-SHIFT | KEY-SHIFT = fn [] i64 | Exported ui/widgets/KEY-SHIFT operation. |
KEY-CTRL | KEY-CTRL = fn [] i64 | Exported ui/widgets/KEY-CTRL operation. |
KEY-ALT | KEY-ALT = fn [] i64 | Exported ui/widgets/KEY-ALT operation. |
KEY-ESC | KEY-ESC = fn [] i64 | Exported ui/widgets/KEY-ESC operation. |
KEY-SPACE | KEY-SPACE = fn [] i64 | Exported ui/widgets/KEY-SPACE operation. |
KEY-PAGE-UP | KEY-PAGE-UP = fn [] i64 | Exported ui/widgets/KEY-PAGE-UP operation. |
KEY-PAGE-DOWN | KEY-PAGE-DOWN = fn [] i64 | Exported ui/widgets/KEY-PAGE-DOWN operation. |
KEY-END | KEY-END = fn [] i64 | Exported ui/widgets/KEY-END operation. |
KEY-HOME | KEY-HOME = fn [] i64 | Exported ui/widgets/KEY-HOME operation. |
KEY-LEFT | KEY-LEFT = fn [] i64 | Exported ui/widgets/KEY-LEFT operation. |
KEY-UP | KEY-UP = fn [] i64 | Exported ui/widgets/KEY-UP operation. |
KEY-RIGHT | KEY-RIGHT = fn [] i64 | Exported ui/widgets/KEY-RIGHT operation. |
KEY-DOWN | KEY-DOWN = fn [] i64 | Exported ui/widgets/KEY-DOWN operation. |
KEY-DELETE | KEY-DELETE = fn [] i64 | Exported ui/widgets/KEY-DELETE operation. |
dark-theme | dark-theme = fn [] Theme | Default dark theme (Slate 900 / Cyan 400). |
light-theme | light-theme = fn [] Theme | Default crisp studio light theme (Slate 50 / Sky 600). |
new-state | new-state = fn [] UiState | Creates a fresh UiState. |
register-focusable | register-focusable = fn [mut st UiState, id str] bool | Registers id in the current frame's Tab-focus ring (respecting st.focus_scope_prefix) and returns true when id is focused. |
cycle-focus | cycle-focus = fn [mut st UiState, reverse bool] str | Advances (reverse == false) or reverses (reverse == true) st.focused_id along st.focus_order. |
draw-focus-ring | draw-focus-ring = fn [mut c cv/Canvas, r Rect, radius i64, th Theme] | Draws a soft keyboard focus halo + border ring around r. |
apply-key | apply-key = fn [mut st UiState, key i64, text_ch i64, sh bool, ct bool, al bool] | Injects a deterministic keyboard event (key, text_ch, and optional /shift, /ctrl, /alt modifiers) for scripted UI frames & tests. |
apply-mouse | apply-mouse = fn [mut st UiState, x i64, y i64, down bool, clicked bool] | Updates pointer coordinates and click state for the current frame. |
apply-events | apply-events = fn [mut st UiState, events block] bool | Feeds a frame batch of ui/UiEvent structs (or maps with .kind, .x, .y, .key, .btn) into st. |
rect-contains? | rect-contains? = fn [r Rect, px i64, py i64] bool | Returns true if point (px, py) lies inside r. |
inset | inset = fn [r Rect, pad i64] Rect | Shrinks r uniformly on all 4 sides by pad pixels. |
inset-edges | inset-edges = fn [r Rect, top i64, right i64, bottom i64, left i64] Rect | Insets r asymmetrically by (top, right, bottom, left). |
vstack | vstack = fn [bounds Rect, heights block, gap i64] block[Rect] | Splits bounds vertically into stacked Rects with fixed heights and spacing gap. |
hstack | hstack = fn [bounds Rect, widths block, gap i64] block[Rect] | Splits bounds horizontally into side-by-side Rects with fixed widths and spacing gap. |
px | px = fn [pixels i64] lay/Track | Creates a fixed-pixel flex track (lay/Track). |
flex | flex = fn [weight i64] lay/Track | Creates a proportional flex-grow track (lay/Track). |
flex-row | flex-row = fn [bounds Rect, tracks block[lay/Track], gap i64] block[Rect] | Solves horizontal flex columns inside bounds using w/px and w/flex tracks. |
flex-col | flex-col = fn [bounds Rect, tracks block[lay/Track], gap i64] block[Rect] | Solves vertical flex rows inside bounds using w/px and w/flex tracks. |
grid | grid = fn [bounds Rect, rows i64, cols i64, gap i64] block[Rect] | Solves a rows x cols uniform 2D grid inside bounds (row-major). |
push-clip | push-clip = fn [mut st UiState, mut c cv/Canvas, r Rect] | Pushes a nested clipping rectangle onto st and activates it on c. |
pop-clip | pop-clip = fn [mut st UiState, mut c cv/Canvas] | Pops the top clipping rectangle from st and restores the previous clip on c. |
panel | panel = fn [mut c cv/Canvas, r Rect, title str, th Theme] | Widget 1: Draws a rounded surface card with a 1px border and optional header title band. |
panel-body | panel-body = fn [r Rect, has_title bool, pad i64] Rect | Returns the usable inner body Rect of a panel below its header band. |
label | label = fn [mut c cv/Canvas, x i64, y i64, text str, scale i64, col cv/Color] | Widget 2: Draws mixed-case proportional UI text at (x, y). |
heading | heading = fn [mut c cv/Canvas, x i64, y i64, text str, scale i64, col cv/Color] | Draws semi-bold heading text at (x, y). |
button | button = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, text str, th Theme, is_primary bool] bool | Widget 3: Draws an interactive rounded button and returns true when clicked in this frame. Supports /primary true for high-emphasis accent fill. |
icon-button | icon-button = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, icon str, th Theme] bool | Widget 4: Draws a compact vector icon button ('plus', 'check', 'close', 'search', 'refresh', 'play', 'folder', 'settings'). |
badge | badge = fn [mut c cv/Canvas, x i64, y i64, text str, kind str, th Theme] i64 | Widget 5: Draws a semantic pill badge (kind in 'ok', 'warn', 'err', 'info', 'neutral') and returns its width. |
stat-card | stat-card = fn [mut c cv/Canvas, r Rect, title str, metric str, delta str, kind str, th Theme] | Widget 6: Draws a KPI metric summary card with muted label, bold scale-2 metric, and delta status badge. |
text-input | text-input = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, val str, placeholder str, th Theme, masked bool] str | Widget 7: Interactive single-line text input with placeholder, focus ring, keyboard editing, and optional /secret bullet masking. |
secret-input | secret-input = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, mut secret_buf secret bytes, bullet_count i64, placeholder str, th Theme] i64 | .secret-safe masked input widget operating directly on a mut secret bytes buffer without converting to str. |
text-area | text-area = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, val str, th Theme] str | Widget 8: Multi-line editable text area with line numbers and clipped viewport. |
checkbox | checkbox = fn [mut c cv/Canvas, mut st UiState, id str, x i64, y i64, text str, checked bool, th Theme] bool | Widget 9: Interactive checkbox with crisp vector checkmark and clickable label; returns updated checked state. |
toggle-switch | toggle-switch = fn [mut c cv/Canvas, mut st UiState, id str, x i64, y i64, text str, on bool, th Theme] bool | Widget 10: Interactive pill toggle switch with sliding circular thumb; returns updated on state. |
radio-group | radio-group = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, options block, selected i64, th Theme] i64 | Widget 11: Interactive radio button group (options list) stacked vertically inside r; returns selected index. |
slider | slider = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, val i64, min_v i64, max_v i64, th Theme] i64 | Widget 12: Horizontal range slider (min_v..max_v) with filled track, circular thumb, and value label; returns updated value. |
progress-bar | progress-bar = fn [mut c cv/Canvas, r Rect, pct i64, th Theme, show_pct bool] | Widget 13: Draws a horizontal progress bar inside r filled to pct (0..100). |
dropdown | dropdown = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, options block, selected i64, th Theme] i64 | Widget 14: Select dropdown trigger + popup menu (st.open_popup_id == id controls open state); returns selected index. |
chip-group | chip-group = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, labels block, active_flags block, th Theme] i64 | Widget 15: Horizontal filter/tag chip group (active_flags bool list); toggles clicked chip and returns clicked index (or -1). |
tabs | tabs = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, labels block, active i64, th Theme] i64 | Widget 16: Segmented single-view tab bar (labels); returns the active tab index. |
begin-scroll | begin-scroll = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, content_h i64, scroll_y i64, th Theme] i64 | Widget 17: Begins a clipped scrollable viewport with scrollbar track/thumb and mouse-wheel scrolling; returns updated scroll_y. |
end-scroll | end-scroll = fn [mut st UiState, mut c cv/Canvas] | Ends a begin-scroll viewport and restores the parent clip rectangle. |
list-view | list-view = fn [mut c cv/Canvas, r Rect, items block, selected i64, th Theme] | Widget 18: Draws a selectable list view inside r (backward-compatible 5-arg form). |
select-list | select-list = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, items block, selected i64, th Theme] i64 | Interactive list view returning the newly selected row index on click or Up/Down arrow keys. |
data-table | data-table = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, headers block, col_tracks block[lay/Track], rows block, selected_row i64, th Theme] i64 | Widget 19: Multi-column data table (headers str list, col_tracks lay/Track list, rows 2D block) with zebra rows & row selection. |
tree-view | tree-view = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, nodes block[TreeNode], selected_id str, th Theme] str | Widget 20: Hierarchical tree view (nodes of TreeNode) with disclosure triangles, folder/item icons, and optional badges. |
split-pane | split-pane = fn [mut c cv/Canvas, mut st UiState, id str, bounds Rect, vertical bool, ratio_pct i64, th Theme] block[Rect] | Widget 21: Resizable horizontal or vertical split pane; draws interactive grip handle and returns [first_rect, second_rect]. |
split-pane-state | split-pane-state = fn [mut c cv/Canvas, mut st UiState, id str, bounds Rect, vertical bool, ratio_pct i64, th Theme] SplitResult | Stateful mouse-draggable variant of split-pane returning SplitResult { first, second, ratio_pct }. |
menu-bar | menu-bar = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, brand str, items block, active_idx i64, th Theme] i64 | Widget 22: Top application menu bar (items str list); returns clicked menu index (or -1). |
context-menu | context-menu = fn [mut c cv/Canvas, mut st UiState, id str, x i64, y i64, w_px i64, items block, th Theme] i64 | Widget 23: Floating context menu card (items of [label shortcut] or str, '-' for divider); returns clicked item index (or -1). |
modal | modal = fn [mut c cv/Canvas, mut st UiState, id str, viewport Rect, dialog_w i64, dialog_h i64, title str, th Theme] ModalResult | Widget 24: Modal lightbox overlay over viewport; draws dimmed backdrop + centered card + close button, returning ModalResult. |
toast | toast = fn [mut c cv/Canvas, r Rect, title str, message str, kind str, th Theme] | Widget 25: Non-blocking toast notification card (kind in 'ok', 'warn', 'err', 'info'). |
tooltip | tooltip = fn [mut c cv/Canvas, x i64, y i64, text str, th Theme] | Widget 26: Floating high-contrast tooltip callout anchored at (x, y). |
sparkline | sparkline = fn [mut c cv/Canvas, r Rect, vals block, col cv/Color, th Theme] | Widget 27: Draws an anti-aliased sparkline with soft area tint inside r normalized to [min(vals)..max(vals)]. |
bar-chart | bar-chart = fn [mut c cv/Canvas, r Rect, categories block, values block, bar_col cv/Color, th Theme] | Widget 28: Labeled vertical column chart with gridlines, Y-axis scale ticks, value labels, and category axis. |
line-chart | line-chart = fn [mut c cv/Canvas, r Rect, x_labels block, series_list block[ChartSeries], th Theme] | Widget 29: Multi-series anti-aliased line chart (series_list of ChartSeries) with gridlines, markers, X labels, and legend. |
new-editor | new-editor = fn [initial str] EditorState | Creates a fresh EditorState initialized with initial source text and cursor at the end. |
code-editor | code-editor = fn [mut c cv/Canvas, mut st UiState, id str, r Rect, mut ed EditorState, th Theme] str | Widget 30: Multi-line Veko studio code editor with line numbers, click/drag & Shift selection, clipboard (Ctrl+A/C/X/V), 64-step Ctrl+Z/Ctrl+Y undo/redo, auto-indent, and Veko syntax highlighting. |
fuzzy-score | fuzzy-score = fn [query str, candidate str] i64 | Pure-Veko subsequence + word-boundary + consecutive-run fuzzy scorer (-1 if query does not match candidate). |
command-palette | command-palette = fn [mut c cv/Canvas, mut st UiState, id str, viewport Rect, mut ps PaletteState, items block[CommandItem], th Theme] str | Widget 31: Fuzzy-searchable Studio Command Palette overlay (Ctrl+K / Ctrl+P style). Returns the executed CommandItem.id (and closes ps.open = false), or '' if still open / dismissed. |
entries-from-list | entries-from-list = fn [items block] block[FileEntry] | Converts { name = str, is_dir = bool, size = i64 } maps (e.g. from fs/list-entries) into typed FileEntry values. |
file-picker | file-picker = fn [mut c cv/Canvas, mut st UiState, id str, viewport Rect, mut fp FilePickerState, entries block[FileEntry], th Theme, is_save bool] FilePickerResult | Widget 32: Pure-Veko zero-capability modal File Picker (entries of FileEntry, /save true for Save dialog). Returns FilePickerResult with action in .none, .selected, .cancelled, or .chdir. |
Verified Doctest (ui/widgets/vstack)
VEKO
use [w = ui/widgets]
rows = w/vstack (w/Rect { x = 10, y = 10, w = 200, h = 100 }) [20 30] 8
if (len rows) != 2 or rows[1].y != 38 [ err 'vstack' ] else [ .ok ]Module ui/x11
Exported Structs & Interfaces
X11Setup:X11Setup = struct { id_base i64, id_mask i64, root_window i64, white_pixel i64, root_visual i64, root_depth i64 }— Parsed X11 server setup parameters for the default root screen.X11Band:X11Band = struct { y i64, height i64, req_words i64, byte_count i64 }— One scanline band descriptor (yoffset +heightrows) for chunkedPutImagetransmission.X11Event:X11Event = struct { kind i64, x i64, y i64, key i64, btn i64 }— Decoded 32-byte X11 wire event mapped to canonical Vekouievent fields(kind, x, y, key, btn).
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
display-socket-path | display-socket-path = fn [display str] str | Resolves the canonical AF_UNIX socket path (e.g. '/tmp/.X11-unix/X0') from a DISPLAY string (':0', 'unix:1.0'). |
parse-xauthority-cookie | parse-xauthority-cookie = fn [raw bytes] bytes | Extracts the first 16-byte MIT-MAGIC-COOKIE-1 token from raw .Xauthority bytes (or empty bytes if absent). |
encode-setup | encode-setup = fn [cookie bytes] bytes | Encodes the little-endian X11 connection setup packet (12 bytes unauthenticated, or 48 bytes with a 16-byte MIT-MAGIC-COOKIE-1). |
parse-setup-reply | parse-setup-reply = fn [pkt bytes] X11Setup | Parses a complete X11 Setup reply buffer (8-byte header + body) into X11Setup. |
encode-window-init | encode-window-init = fn [setup X11Setup, wid i64, gcid i64, title str, w i64, h i64] bytes | Encodes pipelined CreateWindow + CreateGC + ChangeProperty(WM_NAME) + MapWindow core requests. |
plan-put-image-bands | plan-put-image-bands = fn [w i64, h i64] block[X11Band] | Plans scanline bands (<= 128 KB pixel payload per packet) so PutImage never exceeds X11's 16-bit 4-byte-word request cap (262,140 bytes). |
encode-put-image-band | encode-put-image-band = fn [wid i64, gcid i64, depth i64, rgba bytes, w i64, band X11Band] bytes | Encodes one 24-byte PutImage (ZPixmap) band packet + BGRA-swizzled scanlines from rgba. |
decode-event-32 | decode-event-32 = fn [ev bytes] X11Event | Decodes a 32-byte X11 wire event packet into a canonical X11Event (kind = 0 when ignored). |
Verified Doctest (ui/x11/display-socket-path)
VEKO
use [x11 = ui/x11]
p0 = x11/display-socket-path ':0'
p2 = x11/display-socket-path 'unix:2.0'
if p0 != '/tmp/.X11-unix/X0' or p2 != '/tmp/.X11-unix/X2' [ err 'bad x11 path' ] else [ .ok ]Module ui
Exported Structs & Interfaces
UiEvent:UiEvent = struct { kind i64, x i64, y i64, key i64, btn i64 }— Structured window input event decoded frompoll-events.Window:Window = struct { handle i64, width i64, height i64, title str }— Handle to an open native or offscreen window surface.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
EV-CLOSE | EV-CLOSE = fn [] i64 | Window event kind constants matching the 5-element PAL event tuples [kind x y key btn]. |
EV-KEY | EV-KEY = fn [] i64 | Exported ui/EV-KEY operation. |
EV-MOUSE-DOWN | EV-MOUSE-DOWN = fn [] i64 | Exported ui/EV-MOUSE-DOWN operation. |
EV-MOUSE-UP | EV-MOUSE-UP = fn [] i64 | Exported ui/EV-MOUSE-UP operation. |
EV-MOUSE-MOVE | EV-MOUSE-MOVE = fn [] i64 | Exported ui/EV-MOUSE-MOVE operation. |
EV-RESIZE | EV-RESIZE = fn [] i64 | Exported ui/EV-RESIZE operation. |
EV-TEXT | EV-TEXT = fn [] i64 | Exported ui/EV-TEXT operation. |
EV-WHEEL | EV-WHEEL = fn [] i64 | Exported ui/EV-WHEEL operation. |
EV-KEY-UP | EV-KEY-UP = fn [] i64 | Exported ui/EV-KEY-UP operation. |
MOD-SHIFT | MOD-SHIFT = fn [] i64 | Keyboard modifier bitmask constants (UiEvent.btn on EV-KEY / EV-KEY-UP or UiState.key_mods). |
MOD-CTRL | MOD-CTRL = fn [] i64 | Exported ui/MOD-CTRL operation. |
MOD-ALT | MOD-ALT = fn [] i64 | Exported ui/MOD-ALT operation. |
KEY-BACKSPACE | KEY-BACKSPACE = fn [] i64 | Standard cross-platform virtual key constants (UiEvent.key on EV-KEY / EV-KEY-UP). |
KEY-TAB | KEY-TAB = fn [] i64 | Exported ui/KEY-TAB operation. |
KEY-ENTER | KEY-ENTER = fn [] i64 | Exported ui/KEY-ENTER operation. |
KEY-SHIFT | KEY-SHIFT = fn [] i64 | Exported ui/KEY-SHIFT operation. |
KEY-CTRL | KEY-CTRL = fn [] i64 | Exported ui/KEY-CTRL operation. |
KEY-ALT | KEY-ALT = fn [] i64 | Exported ui/KEY-ALT operation. |
KEY-ESC | KEY-ESC = fn [] i64 | Exported ui/KEY-ESC operation. |
KEY-SPACE | KEY-SPACE = fn [] i64 | Exported ui/KEY-SPACE operation. |
KEY-PAGE-UP | KEY-PAGE-UP = fn [] i64 | Exported ui/KEY-PAGE-UP operation. |
KEY-PAGE-DOWN | KEY-PAGE-DOWN = fn [] i64 | Exported ui/KEY-PAGE-DOWN operation. |
KEY-END | KEY-END = fn [] i64 | Exported ui/KEY-END operation. |
KEY-HOME | KEY-HOME = fn [] i64 | Exported ui/KEY-HOME operation. |
KEY-LEFT | KEY-LEFT = fn [] i64 | Exported ui/KEY-LEFT operation. |
KEY-UP | KEY-UP = fn [] i64 | Exported ui/KEY-UP operation. |
KEY-RIGHT | KEY-RIGHT = fn [] i64 | Exported ui/KEY-RIGHT operation. |
KEY-DOWN | KEY-DOWN = fn [] i64 | Exported ui/KEY-DOWN operation. |
KEY-DELETE | KEY-DELETE = fn [] i64 | Exported ui/KEY-DELETE operation. |
BTN-LEFT | BTN-LEFT = fn [] i64 | Mouse button constants carried in UiEvent.btn on EV-MOUSE-DOWN / EV-MOUSE-UP. |
BTN-RIGHT | BTN-RIGHT = fn [] i64 | Exported ui/BTN-RIGHT operation. |
open-window | open-window = fn [title str, w i64, h i64] Window | Opens a window surface titled title with dimensions w x h. |
poll | poll = fn [win Window] block[UiEvent] | Polls all pending OS input events for win without blocking. |
present-rgba | present-rgba = fn [win Window, rgba bytes, w i64, h i64] | Presents a raw RGBA32 byte buffer (w * h * 4 bytes) to win. |
present-canvas | present-canvas = fn [win Window, c cv/Canvas] | Presents a ui/canvas Canvas directly to win. |
close-window | close-window = fn [win Window] | Closes win and releases OS/offscreen surface resources. |
window-dpi-scale | window-dpi-scale = fn [win Window] i64 | Queries the active Hi-DPI scaling percentage for win (100 = 96 DPI 1x, 150 = 1.5x, 200 = 2x Retina/4K). |
clipboard-text | clipboard-text = fn [] str | Reads UTF-8 plain text from the OS/session clipboard. |
clipboard-secret | clipboard-secret = fn [] secret str | Reads clipboard contents directly into a .secret-tainted str for pasting tokens/passwords without exposing plain str copies. |
set-clipboard | set-clipboard = fn [text str] | Writes plain text to the OS/session clipboard (.secret values are statically and dynamically rejected). |
Verified Doctest (ui/open-window)
VEKO
use [ui, cv = ui/canvas]
win = ui/open-window 'Veko Window' 64 32
mut c = cv/new-canvas 64 32
cv/clear mut c (cv/color-bg-dark)
_ = ui/present-canvas win c
evs = ui/poll win
_ = ui/close-window win
if (len evs) < 0 [ err 'events' ] else [ .ok ]Module web
Exported Structs & Interfaces
Request:Request = struct { method str, path str, target str, query map[str], params map[str], headers map[str], body bytes }— Parsed HTTP/1.1 request passed to route handlers and middleware.Response:Response = struct { status i64 = ..., reason str = ..., headers map[str] = ..., body bytes = ..., has_stream bool = ..., stream any = ..., stream_len i64 = ..., file_path str = ..., file_off i64 = ... }— HTTP/1.1 / HTTP/2 / HTTP/3 response returned by handlers and middleware (supports eagerbody, positioned file streaming, andio/Streamchunked/fixed streaming).Route:Route = struct { method str, pattern str, handler any }— Single route entry (method:'GET','POST','ANY', etc.;pattern:'/users/:id').MultipartPart:MultipartPart = struct { name str, filename str, content_type str, data bytes }— One parsed part from amultipart/form-datarequest body.App:App = struct { routes block[Route], middlewares block[any], static_prefix str = ..., static_root str = ..., max_header_bytes i64 = ..., max_body_bytes i64 = ... }— Web application container holding routes, middleware, body/header limits, and optional static file mount.AsyncServerOpts:AsyncServerOpts = struct { max_requests i64 = ..., max_connections i64 = ..., max_reqs_per_conn i64 = ..., read_timeout dur = ..., idle_timeout dur = ..., tick_timeout dur = ..., max_header_bytes i64 = ..., max_body_bytes i64 = ... }— Configuration forserve-reactor.AsyncConn:AsyncConn = struct { sock i64, token i64, state enum, rx bytes, tx bytes, tx_off i64, hdr_end i64, content_len i64, started_ns i64, reqs_served i64 = ..., keep_alive bool = ..., file_path str = ..., file_off i64 = ..., file_rem i64 = ... }— Per-connection non-blocking HTTP/1.1 state machine tracked insideserve-reactor(supportskeep-alivereuse & positioned file streaming).HttpsServerOpts:HttpsServerOpts = struct { max_requests i64 = ..., max_reqs_per_conn i64 = ..., handshake_timeout dur = ..., idle_timeout dur = ..., alt_svc str = ... }— Configuration forserve-tls-conn-opts,serve-https, andhttps-worker-loop.
Exported Functions
| Symbol | Signature | Description |
|---|---|---|
status-reason | status-reason = fn [code i64] str | Maps standard HTTP status codes to default reason phrases. |
new-app | new-app = fn [] App | Creates a new empty App. |
add-route | add-route = fn [mut app App, method str, pattern str, handler any] | Registers a route handler (fn [req Request] Response) on app. |
get | get = fn [mut app App, pattern str, handler any] | Registers a GET route handler (also automatically serves HEAD with empty body unless an explicit HEAD route matches first). |
head | head = fn [mut app App, pattern str, handler any] | Registers an explicit HEAD route handler. |
post | post = fn [mut app App, pattern str, handler any] | Registers a POST route handler. |
put-route | put-route = fn [mut app App, pattern str, handler any] | Registers a PUT route handler. |
delete-route | delete-route = fn [mut app App, pattern str, handler any] | Registers a DELETE route handler. |
use-mw | use-mw = fn [mut app App, mw any] | Appends a middleware (fn [req Request, next any] Response) to app. |
mount-static | mount-static = fn [mut app App, url_prefix str, root_dir str] | Mounts a static file directory under url_prefix (e.g. '/static'). |
response | response = fn [status i64, content_type str, body bytes] Response | Builds a generic Response with explicit status, content-type, and body bytes. |
stream-response | stream-response = fn [status i64, content_type str, s io/Stream, content_len i64] Response | Builds a streaming Response reading from s (content_len >= 0 emits Content-Length; content_len < 0 emits HTTP/1.1 Transfer-Encoding: chunked). |
chunked-response | chunked-response = fn [status i64, content_type str, s io/Stream] Response | Builds an HTTP/1.1 Transfer-Encoding: chunked (or HTTP/2 DATA-streamed) Response from s. |
encode-chunk | encode-chunk = fn [chunk bytes] bytes | Formats a single HTTP/1.1 chunk (<hex>\r\n<chunk>\r\n, or '0\r\n\r\n' when len chunk == 0). |
text | text = fn [status i64, body str] Response | Builds a UTF-8 text/plain response. |
html | html = fn [status i64, body str] Response | Builds a UTF-8 text/html response. |
view | view = fn [status i64, node any] Response | Renders a pure-Veko html/Node or Hiccup component block ([.div { class = 'x' } ['hi']]) as a text/html response. |
page | page = fn [status i64, title str, head_extra block, body_children block] Response | Renders a complete HTML5 <!DOCTYPE html> document from pure-Veko components as a text/html response. |
json-resp | json-resp = fn [status i64, val any] Response | Builds an application/json response by JSON-encoding val. |
redirect | redirect = fn [status i64, location str] Response | Builds a redirect response (302 or 301). |
sse-event | sse-event = fn [event_name str, data str, id str] str | Formats one Server-Sent Events (SSE) payload (event: ...\ndata: ...\n\n). |
sse-resp | sse-resp = fn [payload str] Response | Builds a text/event-stream SSE response containing one or more formatted events. |
sse-write | sse-write = fn [mut stream io/Stream, event_name str, data str, id str] i64 | Streams a live Server-Sent Event frame directly over an open io/Stream. |
build-multipart | build-multipart = fn [boundary str, fields map[str], files block[MultipartPart]] bytes | Encodes an RFC 7578 multipart/form-data payload from text fields and binary files. |
bad-request | bad-request = fn [msg str] Response | Convenience error responses. |
unauthorized | unauthorized = fn [msg str] Response | Exported web/unauthorized operation. |
not-found | not-found = fn [msg str] Response | Exported web/not-found operation. |
server-error | server-error = fn [msg str] Response | Exported web/server-error operation. |
header | header = fn [req Request, name str, default_val str] str | Looks up a request header case-insensitively (returns default_val if absent). |
query-get | query-get = fn [req Request, key str, default_val str] str | Returns a query parameter or default_val. |
param | param = fn [req Request, key str, default_val str] str | Returns a matched :param route parameter or default_val. |
bind-json | bind-json = fn [req Request] any | Decodes a JSON request body into a Veko value. |
bind-form | bind-form = fn [req Request] map[str] | Decodes an application/x-www-form-urlencoded request body into map[str]. |
cookie-get | cookie-get = fn [req Request, name str, default_val str] str | Extracts a named cookie value from the Cookie request header (or default_val if absent). |
match-pattern | match-pattern = fn [pattern str, path str] map | Matches a route pattern like '/users/:id/posts/*rest' against path. Returns { ok = true, params = map } or { ok = false, params = {} }. |
parse-multipart | parse-multipart = fn [body bytes, boundary str] block[MultipartPart] | Parses a multipart/form-data body given its boundary string. |
mime-type | mime-type = fn [path str] str | Maps common file extensions to MIME types. |
stream-file-range | stream-file-range = fn [root_dir str, rel_path str, range_hdr str] Response | Streams a static file (supporting Range: bytes=... 206 Partial Content) in 64 KiB positioned os/pread chunks with zero whole-file RAM allocation. |
stream-file | stream-file = fn [root_dir str, rel_path str] Response | Streams a static file confined beneath root_dir without loading the file into RAM. |
serve-static-range | serve-static-range = fn [root_dir str, rel_path str, range_hdr str] Response | Serves a static file safely confined beneath root_dir (binary-safe, supporting HTTP Range: bytes=... 206 Partial Content; automatically switches to 64 KiB positioned file streaming for slices > 256 KiB). |
serve-static | serve-static = fn [root_dir str, rel_path str] Response | Serves a static file safely confined beneath root_dir, rejecting path traversal. |
mw-security-headers | mw-security-headers = fn [req Request, next any] Response | Built-in middleware that attaches defensive HTTP security headers. |
use-security-headers | use-security-headers = fn [mut app App] | Registers the built-in defensive HTTP security headers middleware on app. |
handle-request | handle-request = fn [app App, req Request] Response | Dispatches a Request through app's middleware chain and router (automatically stripping body on HEAD while preserving Content-Length). |
parse-http-request | parse-http-request = fn [raw bytes] Request | Decodes raw HTTP/1.1 wire bytes into a structured Request. |
encode-http-response | encode-http-response = fn [resp Response] bytes | Encodes a Response into HTTP/1.1 wire bytes (materializing streamed payloads if invoked directly). |
write-http-response-stream | write-http-response-stream = fn [mut stream io/Stream, mut resp Response] i64 | Streams resp directly onto stream without whole-file RAM buffering (supports positioned file_path, fixed-length io/Stream, and Transfer-Encoding: chunked). |
read-http-request-stream-limits | read-http-request-stream-limits = fn [mut stream io/Stream, max_header_bytes i64, max_body_bytes i64] Request | Reads a complete HTTP/1.1 request enforcing max_header_bytes and max_body_bytes (returns err 'web: payload too large' on overflow). |
read-http-request-stream | read-http-request-stream = fn [mut stream io/Stream] Request | Reads a complete HTTP/1.1 request (headers + Content-Length or chunked body) from an io/Stream. |
serve-stream | serve-stream = fn [mut stream io/Stream, app App] Response | Serves a single HTTP/1.1 request/response exchange over any io/Stream (TCP, TLS 1.3, or memory). |
serve-once | serve-once = fn [ln any, app App] Response | Accepts one connection from a TCP listener ln (net/listen-tcp) and serves one request. |
serve-loop | serve-loop = fn [ln any, app App, max_requests i64] i64 | Serves up to max_requests sequential connections on TCP listener ln. |
serve-reactor | serve-reactor = fn [ln any, app App, opts AsyncServerOpts] i64 | Serves concurrent HTTP/1.1 connections on a single thread using the OS readiness reactor (epoll on Linux, kqueue on macOS, IOCP+WSAPoll on Windows, WASI net-poll on Wasm). Supports HTTP/1.1 keep-alive reuse, max_connections DoS protection, 413 body limits, and 64 KiB non-blocking file streaming. |
serve-async | serve-async = fn [ln any, app App, max_requests i64] i64 | Convenience wrapper serving up to max_requests concurrent HTTP/1.1 connections via serve-reactor. |
serve-h2-stream | serve-h2-stream = fn [mut stream io/Stream, app App, max_requests i64, alt_svc str] i64 | Serves an RFC 9113 HTTP/2 connection over stream, dispatching each stream through app (with streaming DATA support & DoS guards). |
serve-tls-conn-opts | serve-tls-conn-opts = fn [sock i64, ident map, app App, opts HttpsServerOpts] i64 | Serves an accepted TCP socket sock over pure-Veko TLS 1.3 (ident) with explicit HttpsServerOpts deadlines & body limits. |
serve-tls-conn | serve-tls-conn = fn [sock i64, ident map, app App, max_requests i64, alt_svc str] i64 | Serves an accepted TCP socket sock over pure-Veko TLS 1.3 (ident), automatically dispatching ALPN 'h2' to serve-h2-stream and 'http/1.1' to serve-stream. |
https-accept-loop | https-accept-loop = fn [ln any, mut cert_reloader map, work_ch any, max_conns i64] i64 | Multi-core shared-nothing HTTPS acceptor: accepts sockets on ln, snapshots closure-free TLS ident from cert_reloader, and dispatches { sock, ident } onto bounded channel work_ch (shedding load cleanly on full backlog). |
https-worker-loop | https-worker-loop = fn [work_ch any, app App, opts HttpsServerOpts] i64 | Multi-core shared-nothing HTTPS worker loop: consumes { sock, ident } jobs from work_ch and serves TLS 1.3 (h2 + http/1.1). |
serve-https | serve-https = fn [ln any, mut cert_reloader map, app App, max_conns i64, alt_svc str] i64 | Serves native HTTPS (TLS 1.3 + ALPN 'h2' / 'http/1.1' + zero-downtime certificate hot-reload) on TCP listener ln multiplexed with reactor so idle HTTP/1.1 keep-alive sockets never block new accepts. |
serve-h3 | serve-h3 = fn [udp_sock i64, get_ident_fn any, app App, max_requests i64] i64 | Serves pure-Veko HTTP/3 over QUIC v1 on bound UDP socket udp_sock (net/udp-bind), dispatching to app. |
make-acme-redirect-app | make-acme-redirect-app = fn [acme_webroot str, domain str, https_port i64] App | Builds a dedicated port :80 App serving RFC 8555 Let's Encrypt /.well-known/acme-challenge/:token from acme_webroot and redirecting (301) all other HTTP requests to https://<domain>[:port]<target>. |
Verified Doctest (web/match-pattern)
VEKO
use [web]
m = web/match-pattern '/api/:ver/items/:id' '/api/v1/items/42'
if not m.ok or (map/get m.params 'ver') != 'v1' or (map/get m.params 'id') != '42' [
err 'route match'
] else [ .ok ]