Skip to main content

Crate twig_sys

Crate twig_sys 

Source
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§

TwigChange
C ABI mirror of Zig’s TwigChange — the byte effect of an edit. old_span is the replaced range in the pre-edit source; new_span is the range the replacement occupies in the post-edit source (same start).
TwigFlatNode
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 or TWIG_NO_NODE. content_span is meaningful only when has_content_span. kind is static, library-owned storage; text/destination pointers borrow the current parse’s payloads (NULL when the kind carries none). head/alignment carry a row/cell payload, each -1 for a kind that has none (see TWIG_HEAD_NONE / TWIG_ALIGN_NONE). name_ptr is a generic element’s tag name — or a directive’s type — and NULL for every other kind; directive_form is a TWIG_DIRECTIVE_NONE-defaulted code for which of the three surface forms a directive took; attrs_ptr points at attrs_len TwigKeyVals (NULL/0 when the node has no attributes). Both borrow the current parse’s payloads with the same lifetime as text_ptr.
TwigKeyVal
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 NULL value is a bare attribute.
TwigQueryMatch
C ABI mirror of Zig’s TwigQueryMatch — one node returned by twig_document_query. content_span is only meaningful when has_content_span is non-zero. kind is a NUL-terminated node-kind name in static, library-owned storage (never freed).
TwigSpan
C ABI mirror of Zig’s TwigSpan — a byte range [start, end).
TwigStatus

Enums§

TwigBuilder
TwigDocument
TwigEditor
TwigFormat

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 the abi_version_matches test in lib.rs).
TWIG_ALIGN_CENTER
TWIG_ALIGN_DEFAULT
TWIG_ALIGN_LEFT
TWIG_ALIGN_NONE
TwigFlatNode::alignment codes; NONE means the node isn’t a cell. NONE is part of the ABI contract even though Alignment::from_c folds it into its catch-all, so spell it out rather than leaving the -1 a mystery.
TWIG_ALIGN_RIGHT
TWIG_DIRECTIVE_CONTAINER
TWIG_DIRECTIVE_LEAF
TWIG_DIRECTIVE_NONE
TwigFlatNode::directive_form codes — the generic-directives proposal’s three spellings: :name[x] (text), ::name{…} (leaf), :::name{…}::: (container). These double as twig_builder_add_directive’s form argument. NONE means the node isn’t a directive at all; like TWIG_ALIGN_NONE it is a read-path-only code, never something you can build with.
TWIG_DIRECTIVE_TEXT
TWIG_HEAD_NONE
TwigFlatNode::head for a node that is neither a row nor a cell.
TWIG_MD_DIRECTIVES
Markdown extension flags for the md_flags bitmask of twig_parse_ext and twig_editor_create_ext.
TWIG_MD_HTML_ELEMENTS
TWIG_MD_MATH
TWIG_NO_NODE
The sentinel node_id for “no such node” in a TwigFlatNode link 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_image
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