DatumHuePlatform v0.0.24datumhue.com
Contents

handle20 methods, 1 field

Bytes

An opaque byte payload. Every byte-producing API returns one; every byte-consuming API accepts one. Decoders raise on failure. A decoder that suspends returns its result ready to use; the others return an asset handle at once, which :ready() awaits.

Obtained from
datumhue.bytes, datumhue.voxel.world (in its callback), datumhue.bytes.json, datumhue.bytes.kdl, datumhue.bytes.msgpack, datumhue.bytes.zlib, datumhue.bytes.base64, VoxelChunk:read and 6 more
Accepted by
datumhue.bytes.zlib, datumhue.bytes.base64, Storage:set, VoxelChunk:write, Shader:reload, Image:update, Dir:write, File:write and 4 more

Fields 1

FieldTypeAccessDescription
stateReadyStateread-onlyCompletion state of this operation. Reading it never raises or suspends; a failed operation's error surfaces at :ready().

Methods 20

Bytes:ready

methodsuspends
Bytes:ready() -> Bytes

Read file-backed bytes into memory now, then return the same handle for chaining. In-memory bytes return at once; decoding bytes read this way does not read the file again. Raises if the read fails.

Bytes:size

methodsuspends
Bytes:size() -> integer

Byte length.

Bytes:text

methodsuspends
Bytes:text() -> string

Return the bytes as a Lua string. UTF-8 is not validated; bytes are returned verbatim.

Bytes:json

methodsuspends
Bytes:json() -> any

Parse the bytes as JSON. Raises on parse failure.

Example
local reply = datumhue.bytes('{"name": "Ada", "scores": [3, 5]}'):json()
print(reply.name, reply.scores[2]) --> Ada 5

Bytes:kdl

methodsuspends
Bytes:kdl() -> any

Parse the bytes as KDL into a table. Each node becomes the key named after it, and sibling nodes that share a name become an array of their values, in order. A node with no values and no children reads as true; one with a single value, positional or a property, reads as that value. A node with several positional values and nothing else reads as an array of them. Any other node reads as a table holding its positional values at 1, 2 and so on, its properties under their names, and its children by these same rules. Type annotations, comments, ordering and layout do not carry over. Raises on parse failure or non-UTF-8 input.

Example
local text = [[
title "Notes"
tags "birds" "trees"
fullscreen
window width=800 { font size=14; }
plugin "maps"
plugin "notes"
]]
local cfg = datumhue.bytes(text):kdl()
print(cfg.title, cfg.tags[2], cfg.fullscreen) --> Notes trees true
print(cfg.window.width, cfg.window.font) --> 800 14
print(cfg.plugin[1], cfg.plugin[2]) --> maps notes

Bytes:msgpack

methodsuspends
Bytes:msgpack() -> any

Parse the bytes as MessagePack. Raises on parse failure.

Example
local player = { name = "Ada", tags = { "x", "y" } }
local value = datumhue.bytes.msgpack(player):msgpack()
print(value.name, value.tags[2]) --> Ada y

Bytes:zlib

methodsuspends
Bytes:zlib(opts?: bytes.ZlibOptions) -> Bytes

Decompress zlib-format bytes. Raises when they are damaged, cut short or fail their checksum, or would unpack to more than max_size bytes.

Example
local packed = datumhue.bytes.zlib("hello, hello, hello")
print(packed:zlib():text()) --> hello, hello, hello
-- A cap refuses data that would grow too large.
local ok = pcall(function()
    return packed:zlib({ max_size = 5 })
end)
print(ok) --> false

opts bytes.ZlibOptions options 1 key

KeyTypeDefaultDescription
max_sizeinteger16777216The most bytes the result may hold; raises below 1.

Bytes:base64

methodsuspends
Bytes:base64() -> Bytes

Decode the bytes as base64 in either alphabet, padded or not, skipping ASCII whitespace. Raises on any other character, or when the text stops partway through a byte.

Example
local code = datumhue.bytes("aGk_"):base64()
print(code:text()) --> hi?

Bytes:csv

methodsuspends
Bytes:csv(opts?: bytes.CsvOptions) -> DataHandle

Decode the bytes as CSV into a DataHandle. Raises on parse failure.

Example
local csv = "# station 4\ncity;temp\nOslo;4\nRome;18\n"
local rows = datumhue.bytes(csv):csv({ delimiter = ";", comment = "#" })
print(rows:count()) --> 2

opts bytes.CsvOptions options 4 keys

KeyTypeDefaultDescription
headerbooleantrueTreat the first row as a header.
delimiterstring","Single-byte field delimiter.
quotestring"\""Single-byte quote character.
commentstringno line is skippedSingle-byte comment marker; matching lines are skipped.

Bytes:parquet

methodsuspends
Bytes:parquet() -> DataHandle

Decode the bytes as Parquet into a DataHandle. Raises on parse failure.

Example
local temps = datumhue.bytes("city,temp\nOslo,4\nRome,18\n"):csv()
local parquet = temps:encode_parquet()
print(parquet:parquet():count()) --> 2

Bytes:shader

method
Bytes:shader(options?: shader.CompileOptions) -> Shader

Compile the bytes as a fragment shader (WGSL, or WESL extended syntax) defining fn dh_fragment(uv: vec2<f32>) -> vec4<f32>. The source may read dh.time, dh.resolution, and dh.mouse (set for each primitive the shader draws), the declared u.<name> uniforms, and the dh_channel0..3 textures. Raises with the failing source line on a compile error. The returned shader applies anywhere a preset does; on a 3D mesh uv is the mesh's texture coordinate, and the mesh shows the returned color as it is, unlit, or, as the shader of material.standard, as a base color the scene lights. Limits per shader: 64 KiB source, 16 uniforms, 4 channels, 127 nested blocks and 255 chained operators and brackets; up to 32 live custom shaders per app.

Example
local source = [[
fn dh_fragment(uv: vec2<f32>) -> vec4<f32> {
    return vec4<f32>(uv.x, uv.y, u.blue, 1.0);
}
]]
local options = { uniforms = { blue = 0.5 } }
local shader = datumhue.bytes(source):shader(options)
shader:set("blue", 1.0)

options shader.CompileOptions options 2 keys

KeyTypeDefaultDescription
uniformstablethe source reads no u.<name> uniformsTable of name = initial declarations the source reads as u.<name>. A number declares an f32, a vec2/vec3 its vector type, a color a vec4<f32>. Capacity 16. A value that is not a table declares none.
channelstableevery channel samples whiteArray of up to 4 texture sources (pixel canvas, draw canvas, or scene) bound as dh_channel0..3; unset channels sample white. A value that is not a table binds none.

Bytes:book

methodsuspends
Bytes:book(opts?: bytes.BookOptions) -> Book

Parse the bytes as a one-chapter book: Markdown prose with elements in kdl fences, or a KDL page (chosen by content). Bytes have no directory to load from, so scripts never run, an image shows its alt text in italics, as [image: alt text], one with no alt text is left out, and include raises. A page from outside the app, such as a package's readme, should be loaded with templates off. Raises on parse or validation errors.

Example
count = 3
local page = "# Notes\n\nThere are {{ count }} notes.\n"
-- The page is the app's own text, so its templates may run.
local book = datumhue.bytes(page):book({ templates = true })
print(book.title, book.pages) --> Notes 1

opts bytes.BookOptions options 1 key

KeyTypeDefaultDescription
templatesbooleanfalseRun the page's {{ }} templates and its if and for elements as Lua in the app's globals, on every render. With templates off, {{ }} in prose shows as written, and an if, a for or a property that holds a template raises at load.

Bytes:image

method
Bytes:image() -> Image

Decode the bytes as an image in whichever format they hold (PNG, JPEG, WebP, etc.). Raises if the format is unsupported or the bytes cannot be decoded.

Bytes:cubemap

method
Bytes:cubemap() -> CubemapAsset

Decode the bytes as a KTX2 cubemap (6 faces) for use as a skybox or environment map. Raises if the bytes are not a KTX2 cubemap; to build one from a vertically-stacked 2D image use image_asset:to_cubemap() instead.

Bytes:audio

method
Bytes:audio() -> AudioAsset

Decode the bytes as WAV or Ogg Vorbis audio, in the background: :ready() waits for it, and a clip longer than 10 seconds is ready once its start is, the rest decoding as it plays. In-memory bytes that are neither raise here; a file that is neither, or audio that does not decode, leaves the asset's .state failed, and playing it raises.

Bytes:wavetable

methodsuspends
Bytes:wavetable() -> Wavetable

A wavetable from the bytes: 2..4096 bytes, each an unsigned level 0..255 held for an equal share of the cycle, the mean removed, played as steps with no interpolation. Any other length raises.

Example
-- Each byte is one level of the cycle, from 0 (lowest) to 255.
local steps = datumhue.bytes(string.char(0, 255, 160, 96, 255, 64))
local wave = steps:wavetable()
datumhue.audio.synth({ waveform = wave, frequency = 110 })

Bytes:font

methodsuspends
Bytes:font() -> Font

Decode the bytes as a font face (TrueType or OpenType). Set it as a text surface's font, as datumhue.font.default, or a fallback via datumhue.font.fallback. Raises at decode if the bytes are not a TrueType/OpenType font (WOFF/WOFF2 are not supported); the returned face is ready at once.

Bytes:scene

method
Bytes:scene() -> SceneAsset

Decode the bytes as a 3D scene (glTF). A scene's buffers and textures load from the files beside it, so the bytes must come from a file or directory grant — decode via file:read():scene() or dir:read(rel):scene(). Bytes lifted from a string raise.

Bytes:theme

methodsuspends
Bytes:theme() -> Theme

Decode the bytes as a theme. Returns a Theme handle, ready to apply.

Bytes:ftl

methodsuspends
Bytes:ftl() -> Ftl

Parse the bytes as a Fluent (.ftl) localization catalog for one locale (declared by its -datumhue-locale term). Returns an Ftl to set as datumhue.i18n.locale. Raises on a missing/invalid locale term or a Fluent syntax error.

Example
local catalog = [[
-datumhue-locale = sv
greeting = Hej
]]
local swedish = datumhue.bytes(catalog):ftl()
print(swedish:locale()) --> sv
datumhue.i18n.locale = swedish

datumhue.com

(c) 2026 Shuusei AB. Quote excerpts of this manual, with attribution to DatumHue, in your own documentation, tutorials, course materials, reviews, and other writing or video. Republishing it in whole or in substantial part needs written permission: support@datumhue.com.

Victor Mono is licensed under the SIL Open Font License 1.1
Copyright (c) 2024, Rune Bjørnerås (https://github.com/rubjo)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Try

    ↑↓ selectEnter openTab filter

    Settings

    Theme
    Text
    Print

    Keyboard shortcuts

    / or Ctrl KSearch
    ↑ ↓ EnterPick a result
    TabNext result filter
    j kNext or previous entry
    [ ]Previous or next page
    yCopy a link to the current entry
    ?These shortcuts
    EscClose

    On this page