Skip to main content

Crate nifty_rt

Crate nifty_rt 

Source
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§

pub use value::BOOL;
pub use value::FLOAT;
pub use value::INT;
pub use value::STRING;

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(…) and format_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; addresses pairs 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(…) and close_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.
BindingDesc
Compiled
Context
Compiled code receives this as an opaque pointer and passes it back on every call.
DownloadBinding
One binding of a download(…) call: the report field, and the state it goes to.
DownloadDesc
A download(…) call as compiled code builds it: the address, folder, name and list of headers, borrowed, its other settings, and len bindings at bindings.
Frame
The locals visible to a piece of UI. A frame owns its values, released when it drops.
FrameDesc
The types of a frame’s locals; a frame starts with every local empty.
MenuDesc
A menu: its title and its entries.
MenuEntryDesc
One entry of a menu. Which fields matter depends on kind:
PathStep
One step of a path: a struct’s field, or a list’s item, by position.
PlaceDesc
A place in state, as compiled code builds one for a call: state state, then len steps at steps.
Prepared
A program whose descriptor checked out and whose state is set up, ready to show.
ProgramDesc
Every function returns false after a runtime call recorded why it failed.
Region
An if, for or view call: compiled code picks which of lists it shows.
RegionDesc
ShortcutDesc
An item’s shortcut, which shortcut holds when present.
Sink
Slice
len items starting at ptr, which live for the rest of the program.
SourceLocation
SpanDesc
StateDesc
Str
UTF-8 text that lives for the rest of the program, laid out as a Slice<u8>.
TemplateDesc
One element of a window’s UI. Which fields matter depends on kind:
TypeDesc
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.
ViewDesc
WindowDesc

Enums§

MenuEntryKind
StepKind
TemplateKind
TypeKind
What kind of value a TypeDesc describes; compiled programs store it as a u8.

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-libs reports 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 program until 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§

ActionFn
Runs a button’s action in a copy of its frame, which it may change.
ExpandFn
Tells sink what a region shows now, through the nf_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 int or a bool, to out; frame holds its locals.
Slot
WriteFn
Writes value, which it takes ownership of, to a bound place.