Expand description
Low-level FFI bindings for Twig’s C ABI, plus the build script that links
the native libtwig.a.
This crate is the -sys layer: it exposes the raw extern "C" functions,
the #[repr(C)] type mirrors, and the status/format constants, and nothing
else. The safe, ergonomic API lives in the twig-doc crate, which depends
on this one. Direct use is unsafe and unstable across ABI-version bumps —
see TWIG_ABI_VERSION.
Structs§
- Twig
Change - C ABI mirror of Zig’s
TwigChange— the byte effect of an edit.old_spanis the replaced range in the pre-edit source;new_spanis the range the replacement occupies in the post-edit source (same start). - Twig
Flat Node - C ABI mirror of Zig’s
TwigFlatNode— one node of the editor’s flat tree snapshot. Link fields (parent/first_child/next_sibling) are ids orTWIG_NO_NODE.content_spanis meaningful only whenhas_content_span.kindis static, library-owned storage;text/destinationpointers borrow the current parse’s payloads (NULL when the kind carries none).head/alignmentcarry arow/cellpayload, each-1for a kind that has none (seeTWIG_HEAD_NONE/TWIG_ALIGN_NONE).name_ptris a generic container’s name — an HTML/XML tag or a directive’s type — and NULL for every other kind;directive_formis aTWIG_DIRECTIVE_NONE-defaulted code for which of the three surface forms it took;container_originis aTWIG_CONTAINER_ORIGIN_NONE-defaulted code for whether it was WRITTEN as a tag or a directive (the two questions are different — see the constants);attrs_ptrpoints atattrs_lenTwigKeyVals (NULL/0 when the node has no attributes). Both borrow the current parse’s payloads with the same lifetime astext_ptr. - Twig
KeyVal - C ABI mirror of Zig’s
TwigKeyVal— one(key, value)attribute pair. Used on the read path (TwigFlatNode::attrs_ptr, borrowed) and the write path (twig_builder_set_attrs, copied). A NULLvalueis a bare attribute. - Twig
Query Match - C ABI mirror of Zig’s
TwigQueryMatch— one node returned bytwig_document_query.content_spanis only meaningful whenhas_content_spanis non-zero.kindis a NUL-terminated node-kind name in static, library-owned storage (never freed). - Twig
Span - C ABI mirror of Zig’s
TwigSpan— a byte range[start, end). - Twig
Status - Twig
Warning - C ABI mirror of Zig’s
TwigWarning— one thing a conversion would silently lose.pathis a slash-separated child-index trail from the analyzed root (empty for the root itself);kindis a NUL-terminated node-kind name in static, library-owned storage. Both borrow, with the lifetime of thetwig_document_diagnosticsoutput array they came from.
Enums§
Constants§
- TWIG_
ABI_ VERSION - The C ABI contract version this binding is written against; see
twig_abi_version. Must match the value baked into the linked library (asserted at runtime by theabi_version_matchestest inlib.rs). - TWIG_
ALIGN_ CENTER - TWIG_
ALIGN_ DEFAULT - TWIG_
ALIGN_ LEFT - TWIG_
ALIGN_ NONE TwigFlatNode::alignmentcodes;NONEmeans the node isn’t acell.NONEis part of the ABI contract even thoughAlignment::from_cfolds it into its catch-all, so spell it out rather than leaving the -1 a mystery.- TWIG_
ALIGN_ RIGHT - TWIG_
CONTAINER_ ORIGIN_ DIRECTIVE - TWIG_
CONTAINER_ ORIGIN_ ELEMENT - TWIG_
CONTAINER_ ORIGIN_ NONE TwigFlatNode::container_origincodes — whether a generic container was WRITTEN as a tag or as a directive.- TWIG_
DIRECTIVE_ CONTAINER - TWIG_
DIRECTIVE_ LEAF - TWIG_
DIRECTIVE_ NONE TwigFlatNode::directive_formcodes — the generic-directives proposal’s three spellings::name[x](text),::name{…}(leaf),:::name{…}…:::(container). These double astwig_builder_add_directive’sformargument.NONEmeans the node isn’t adirectiveat all; likeTWIG_ALIGN_NONEit is a read-path-only code, never something you can build with.- TWIG_
DIRECTIVE_ TEXT - TWIG_
FIDELITY_ DEGRADED - TWIG_
FIDELITY_ DROPPED - TWIG_
FIDELITY_ FAITHFUL TwigWarning::fidelitycodes.FAITHFULcompletes the space and is never the value of a reported warning — a faithful node is not a warning.- TWIG_
HEAD_ NONE TwigFlatNode::headfor a node that is neither arownor acell.- TWIG_
MD_ DIRECTIVES - Markdown extension flags for the
md_flagsbitmask oftwig_parse_extandtwig_editor_create_ext. - TWIG_
MD_ HTML_ ELEMENTS - TWIG_
MD_ MATH - TWIG_
NO_ NODE - The sentinel
node_idfor “no such node” in aTwigFlatNodelink field. - TWIG_
TABLE_ DELETE_ COLUMN - TWIG_
TABLE_ DELETE_ ROW - TWIG_
TABLE_ INSERT_ COLUMN - TWIG_
TABLE_ INSERT_ ROW - TWIG_
TABLE_ MOVE_ COLUMN - TWIG_
TABLE_ MOVE_ ROW - TWIG_
TABLE_ SET_ ALIGNMENT - TWIG_
TASK_ CHECKED_ NONE TwigFlatNode::checkedfor a node that is not atask_list_item.
Functions§
- twig_
abi_ ⚠version - twig_
builder_ ⚠add - twig_
builder_ ⚠add_ bullet_ list - twig_
builder_ ⚠add_ cell - twig_
builder_ ⚠add_ cell_ spanning - twig_
builder_ ⚠add_ citation - twig_
builder_ ⚠add_ code_ block - twig_
builder_ ⚠add_ directive - twig_
builder_ ⚠add_ element - twig_
builder_ ⚠add_ footnote - twig_
builder_ ⚠add_ heading - twig_
builder_ ⚠add_ image - twig_
builder_ ⚠add_ link - twig_
builder_ ⚠add_ metadata - twig_
builder_ ⚠add_ ordered_ list - twig_
builder_ ⚠add_ processing_ instruction - twig_
builder_ ⚠add_ raw_ block - twig_
builder_ ⚠add_ raw_ inline - twig_
builder_ ⚠add_ reference - twig_
builder_ ⚠add_ row - twig_
builder_ ⚠add_ smart_ punctuation - twig_
builder_ ⚠add_ substitution - twig_
builder_ ⚠add_ task_ list - twig_
builder_ ⚠add_ task_ list_ item - twig_
builder_ ⚠add_ text - twig_
builder_ ⚠ast_ json - twig_
builder_ ⚠create - twig_
builder_ ⚠destroy - twig_
builder_ ⚠query - twig_
builder_ ⚠render_ html - twig_
builder_ ⚠serialize - twig_
builder_ ⚠set_ attrs - twig_
builder_ ⚠set_ children - twig_
document_ ⚠ast_ json - twig_
document_ ⚠blank_ line_ prefix - twig_
document_ ⚠cell_ colspan - twig_
document_ ⚠cell_ rowspan - twig_
document_ ⚠children - twig_
document_ ⚠continuation_ prefix - twig_
document_ ⚠definitions - twig_
document_ ⚠destroy - twig_
document_ ⚠diagnostics - twig_
document_ ⚠line_ prefix - twig_
document_ ⚠node_ at - twig_
document_ ⚠node_ at_ caret - twig_
document_ ⚠node_ content_ span - twig_
document_ ⚠node_ marker_ span - twig_
document_ ⚠node_ span - twig_
document_ ⚠nodes - twig_
document_ ⚠nodes_ at - twig_
document_ ⚠nodes_ at_ caret - twig_
document_ ⚠query - twig_
document_ ⚠render_ html - twig_
document_ ⚠serialize - twig_
document_ ⚠subtree - twig_
editor_ ⚠ast_ json - twig_
editor_ ⚠caret_ blob - twig_
editor_ ⚠child_ spans - twig_
editor_ ⚠clear_ dirty - twig_
editor_ ⚠coalesce_ last - twig_
editor_ ⚠create - twig_
editor_ ⚠create_ ext - twig_
editor_ ⚠delete - twig_
editor_ ⚠delete_ smart - twig_
editor_ ⚠destroy - twig_
editor_ ⚠dirty_ range - twig_
editor_ ⚠document - twig_
editor_ ⚠edit_ range - twig_
editor_ ⚠filter - twig_
editor_ ⚠insert_ after - twig_
editor_ ⚠insert_ before - twig_
editor_ ⚠insert_ child - twig_
editor_ ⚠insert_ footnote - twig_
editor_ ⚠insert_ image - twig_
editor_ ⚠insert_ line_ break - twig_
editor_ ⚠insert_ link - twig_
editor_ ⚠insert_ literal - twig_
editor_ ⚠insert_ thematic_ break - twig_
editor_ ⚠last_ change - twig_
editor_ ⚠node_ at - twig_
editor_ ⚠nodes - twig_
editor_ ⚠nodes_ at - twig_
editor_ ⚠query - twig_
editor_ ⚠redo - twig_
editor_ ⚠renumber_ ordered_ lists - twig_
editor_ ⚠replace - twig_
editor_ ⚠replace_ content - twig_
editor_ ⚠revision - twig_
editor_ ⚠set_ block - twig_
editor_ ⚠set_ caret_ blob - twig_
editor_ ⚠set_ code_ language - twig_
editor_ ⚠set_ task_ checked - twig_
editor_ ⚠source - twig_
editor_ ⚠split_ block - twig_
editor_ ⚠subtree - twig_
editor_ ⚠table_ edit - twig_
editor_ ⚠toggle_ block_ container - twig_
editor_ ⚠toggle_ code_ block - twig_
editor_ ⚠toggle_ inline - twig_
editor_ ⚠toggle_ task_ checked - twig_
editor_ ⚠toggle_ task_ item - twig_
editor_ ⚠undo - twig_
editor_ ⚠unwrap - twig_
editor_ ⚠wrap_ range - twig_
parse ⚠ - twig_
parse_ ⚠ext - twig_
version ⚠ - twig_
version_ ⚠string