Expand description
The runtime library compiled Nifty apps link against.
nf build compiles a program to machine code that calls the nf_* functions
symbols names, and emits a ProgramDesc describing its states, windows and
views. The program’s main hands that descriptor to nifty_rt_main, which shows the
windows on the platform’s native UI through the same engine the interpreter uses.
Re-exports§
Modules§
- abi 🔒
- The calls compiled code makes into the runtime, exported unmangled as
nf_*. - context 🔒
- What compiled code runs against: the app’s state, what changed since the UI last caught up, how deep calls are, and why the code last failed.
- dialog 🔒
pick_file(…)and the other file dialogs in compiled apps. The call names the state its answer is bound to as a path from a state, which the answer is written through later.- download 🔒
download(…)andformat_bytes(…)in compiled apps. A download call names the state each of its bindings is bound to as paths from a state, which the reports are written through later.- ffi 🔒
- Plain-data building blocks of the descriptors compiled programs carry: a slice and a string, laid out as a pointer and a length.
- logic 🔒
- Compiled code as the runtime engine’s
Logic: each template’s dynamic parts are compiled functions, which this calls with the app’s context and the template’s frame. - lower 🔒
- Turns a program descriptor’s windows and views into the runtime’s templates, checking each template has what its kind needs.
- place 🔒
- Places in state that compiled code names for writes that happen later, such as where a download reports or a file dialog answers: a state, then a path of fields and items.
- program 🔒
- The descriptor a compiled program hands the runtime: its states, windows, views and the compiled functions behind every dynamic part of their UI.
- show 🔒
- How compiled code says what a region shows: it calls
nf_show_*on the sink it was given, once per template list to show, in order. - symbols
- Everything compiled code links to, by the name it’s exported under. Each function’s
name comes from its own identifier, so the names can’t drift from the exports;
addressespairs every name with what it names, for loading code in-process. - value 🔒
- Values as compiled code holds them: every value fits in a 64-bit
Slot. - window 🔒
open_window(…)andclose_window(…)in compiled apps, which ask for the window by its position among the app’s windows.
Structs§
- AppError
- A failure while the app runs, pointing at the code responsible when the program says where that is.
- Binding
- A text field’s or checkbox’s place: how to read it and how to write the user’s edits.
- Binding
Desc - Compiled
- Context
- Compiled code receives this as an opaque pointer and passes it back on every call.
- Download
Binding - One binding of a
download(…)call: the report field, and the state it goes to. - Download
Desc - A
download(…)call as compiled code builds it: the address, folder, name and list of headers, borrowed, its other settings, andlenbindings atbindings. - Frame
- The locals visible to a piece of UI. A frame owns its values, released when it drops.
- Frame
Desc - The types of a frame’s locals; a frame starts with every local empty.
- Menu
Desc - A menu: its title and its entries.
- Menu
Entry Desc - One entry of a menu. Which fields matter depends on
kind: - Path
Step - One step of a path: a struct’s field, or a list’s item, by position.
- Place
Desc - A place in state, as compiled code builds one for a call: state
state, thenlensteps atsteps. - Prepared
- A program whose descriptor checked out and whose state is set up, ready to show.
- Program
Desc - Every function returns
falseafter a runtime call recorded why it failed. - Region
- An
if,foror view call: compiled code picks which oflistsit shows. - Region
Desc - Shortcut
Desc - An item’s shortcut, which
shortcutholds whenpresent. - Sink
- Slice
lenitems starting atptr, which live for the rest of the program.- Source
Location - Span
Desc - State
Desc - Str
- UTF-8 text that lives for the rest of the program, laid out as a
Slice<u8>. - Template
Desc - One element of a window’s UI. Which fields matter depends on
kind: - Type
Desc - A type, as a compiled program describes it. Struct types may lead back to themselves through their fields, so these form a graph of statics.
- View
Desc - Window
Desc
Enums§
- Menu
Entry Kind - Step
Kind - Template
Kind - Type
Kind - What kind of value a
TypeDescdescribes; compiled programs store it as au8.
Constants§
- ABI_
VERSION - Bumped whenever these layouts or the meaning of a runtime call change, so a program built against another runtime is refused instead of misread.
- EXIT_
FAILED 🔒 - The exit status of an app that stopped with an error.
- NATIVE_
LIBS - The system libraries an app linked with this runtime needs, in the linker’s own
syntax, as
rustc --print native-static-libsreports them for the static library, less-lSystem, which the C compiler driver always links.nf build’s link test fails when one is missing.
Functions§
- nifty_
rt_ ⚠main - Runs
programuntil the app quits, and returns the process’s exit status. An error stops the app, since it leaves the app half-way through a change. - prepare
- Checks
program’s descriptor and sets up its state, before any UI exists.
Type Aliases§
- Action
Fn - Runs a button’s action in a copy of its frame, which it may change.
- Expand
Fn - Tells
sinkwhat a region shows now, through thenf_show_*calls. - InitFn
- Writes a state’s starting value to
out. - ReadFn
- Writes the value a piece of UI shows, such as a string, an
intor abool, toout;frameholds its locals. - Slot
- WriteFn
- Writes
value, which it takes ownership of, to a bound place.