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 element’s tag name (NULL for every other kind);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
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_
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
Functions§
- twig_
abi_ ⚠version - twig_
builder_ ⚠add - twig_
builder_ ⚠add_ bullet_ list - twig_
builder_ ⚠add_ cell - 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_ 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_ ⚠destroy - twig_
document_ ⚠query - twig_
document_ ⚠render_ html - twig_
document_ ⚠serialize - 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_ ⚠edit_ range - twig_
editor_ ⚠filter - twig_
editor_ ⚠insert_ after - twig_
editor_ ⚠insert_ before - twig_
editor_ ⚠insert_ child - twig_
editor_ ⚠insert_ line_ break - twig_
editor_ ⚠insert_ link - twig_
editor_ ⚠insert_ literal - 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_ ⚠source - twig_
editor_ ⚠subtree - twig_
editor_ ⚠table_ edit - twig_
editor_ ⚠toggle_ block_ container - twig_
editor_ ⚠toggle_ inline - twig_
editor_ ⚠undo - twig_
editor_ ⚠unwrap - twig_
editor_ ⚠wrap_ range - twig_
parse ⚠ - twig_
parse_ ⚠ext - twig_
version ⚠ - twig_
version_ ⚠string