Skip to main content

Crate tomlmenu

Crate tomlmenu 

Source
Expand description

Reusable ratatui-driven menuconfig TUI for editing a TOML config file in place.

The library exposes three primary entry points:

  • Document — wraps toml_edit::DocumentMut plus an on-disk path; load/get/set/clear/save with atomic-rename writes.
  • Schema — trait + derive macro. Apply #[derive(Schema)] to any serde-annotated user type to produce a static MenuNode tree. The derive is re-exported from the companion tomlmenu-derive crate under the derive feature, which is enabled by default.
  • App — top-level lifecycle: App::new(schema, document, shadowed) then App::run() -> (ExitReason, Document).

The library is unsafe_code = "deny" and has no opinion about which TOML file you are editing. Consumers own (a) the user struct annotated with #[derive(Schema)], (b) loading the Document, and (c) deciding whether to call Document::save after ExitReason::Saved.

Structs§

App
The top-level menuconfig application.
Document
A mutable view over the on-disk TOML config file.
MenuNode
A node in the menu schema tree.

Enums§

ExitReason
The verdict returned from App::run. The consumer decides whether to persist on Saved (typically by calling Document::save on the returned document) or discard.
LeafKind
Editor kind for a leaf node.
MenuBody
What a MenuNode contains.

Traits§

Schema
A type that exposes a static menu schema.

Functions§

install_panic_hook
Install a panic hook that invokes each RestoreAction in order before re-invoking the previous hook. Replaces any list previously registered with this function.
require_tty
Refuse to start the TUI when stdio is not interactive. Returns Err so the caller surfaces a clear stderr line and exits with code 2.

Type Aliases§

RestoreAction
A side-effect run on panic or normal teardown to restore the terminal.
Result
Library-wide error alias.

Derive Macros§

Schema
The #[derive(Schema)] proc-macro, re-exported from tomlmenu-derive.