Skip to main content

Crate fig

Crate fig 

Source

Modules§

helper
The out-of-process carrier of a runtime language: JSON over stdio. Needs the json feature, since fig reads and writes the wire itself. The out-of-process carrier: a Language served to a fig binary as JSON over stdin and stdout. serve is the request loop a helper executable runs; the wire format below is what the fig CLI’s helper runner speaks, and what a helper in any other language implements.
language
Languages resolved at runtime: the Language trait, the node table its parse returns, and register, which carries an implementation to the core as a vtable and hands back a Format that every entry point of this crate then accepts.

Structs§

Capabilities
What this build of the fig core can do with a format. Reflects both inherent support (every format the Format enum exposes parses, edits, and serializes; the core’s reader-only XML is not surfaced here) and build-time gating (a format compiled out reports all-false).
Document
Editor
An in-place editor over an owned copy of a document’s source.
Embed
An editor over an embedded config region of a host file.
Extracted
The result of Embed::extract: a located Region plus the borrowed host text, with helpers to slice out the embedded content and the host text on either side of it without parsing or copying.
LanguageFailure
Why a runtime language was refused, from Error::Language.
ParseError
Details of a parse failure, projected from the C ABI’s FigError.
Region
A located embed region in host-file byte coordinates (the content is not parsed).
RuntimeFormat
The per-process identity of a Format::Runtime. Opaque; compare it, copy it, do not persist it.
SerializeOptions
Controls how Value::serialize_with renders output. The Default is fig’s historical style (pretty-printed, two-space indent), so Value::serialize is exactly serialize_with(format, SerializeOptions::default()).
Span
A half-open [start, end) byte range: within the host file for an embed’s Region, within the input for a runtime language’s node table. Converts to and from a Range<usize>, so Span::from(0..5) builds one and &source[Range::from(span)] slices by one.
Version
The linked fig library’s version, from version.
Warning
One lossy event a serialization would produce.

Enums§

EmbedType
Which embedded config to open — the flat mirror of fig’s parametric Embed.Type. The three parametric families (markdown ---<lang> frontmatter, ```<lang> fenced blocks, <script type> HTML data islands) are enumerated once per format. Each name is the CLI’s archetype name (--embed semicolons, --embed fenced-fig) in UpperCamelCase, as the TypeScript binding’s string values are.
Error
Errors produced while parsing, serializing, or deserializing.
ExtKind
The kind of a format-specific Value::Extended scalar. Mirrors the core’s ExtKind and the C ABI’s FigExtKind; the discriminants match that ABI.
Format
A config format: every format the core registers, plus Format::Runtime for a language registered while the program runs. Every compiled variant parses, edits, and serializes.
Segment
One step of a path into a document: a mapping key or a sequence index.
Value
An owned, format-independent value tree.
WarningCause
Why a Warning’s loss happens. Mirrors FigWarningCause.
WarningCode
What kind of loss a Warning describes. Mirrors FigWarningCode.

Functions§

capabilities
Query what this build can do with format (read/edit/serialize). Lets a host pick a working format up front instead of probing via UnsupportedFormat.
detect
Best-effort sniff of which embed archetype source uses: try each known archetype’s OPEN delimiter and return the first that matches, or None when source opens none of them. Only the open delimiter is checked — an unterminated block is still recognized as its archetype, so a follow-up Embed::extract/Embed::open surfaces the real error instead of a misleading “nothing found”. The counterpart to fig’s Language.detect, for embeds.
split
Split source around its embedded region of kind without parsing or copying: (before, content, after), the host text before the open fence, the text between the fences, and the host text after the close fence. All three borrow source. For frontmatter before is empty (or a UTF-8 BOM) and after is the prose; for endmatter the other way round; for an HTML data island both sides are host.
version
The version of the linked fig core, decoded from the packed (major << 16) | (minor << 8) | patch that fig_version returns.
version_string
The linked fig core’s version as a "major.minor.patch" string.