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 body without parsing or copying.
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.
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. The first four names are historical (FrontmatterJson is the ;;; block, FrontmatterFig is the ```fig fenced block); the rest are grouped by container.
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 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 an embedded region of kind from its host body without parsing or copying — the read-only (content, body) twin of opening an Embed. None when content has no such region (or its opening fence has no close). Both slices borrow content: the first is the text between the fences (no fences), the second is the host prose outside them.
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.