twig-sys 2.6.0

FFI bindings and native library for Twig (the Djot/Markdown/HTML/XML document engine). Used by the `twig-doc` crate.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
//! 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`].
#![allow(non_camel_case_types)]

use std::os::raw::{c_char, c_int};

/// 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`).
pub const TWIG_ABI_VERSION: u32 = 4;

// Freeze the canonical 64-bit layout of every `#[repr(C)]` mirror below so it
// can never silently drift from the Zig `extern struct` it shadows. These are
// the same offsets asserted on the Zig side in `src/c_abi.zig`; a change on
// either side that isn't matched on the other fails to compile. Gated on 64-bit
// (the offsets are the LP64/LLP64 layout); 32-bit targets pack tighter but the
// C ABI still keeps both languages in agreement.
#[cfg(target_pointer_width = "64")]
const _: () = {
    use std::mem::offset_of;
    use std::mem::size_of;

    assert!(size_of::<TwigSpan>() == 16);
    assert!(offset_of!(TwigSpan, start) == 0);
    assert!(offset_of!(TwigSpan, end) == 8);

    assert!(size_of::<TwigQueryMatch>() == 56);
    assert!(offset_of!(TwigQueryMatch, node_id) == 0);
    assert!(offset_of!(TwigQueryMatch, span) == 8);
    assert!(offset_of!(TwigQueryMatch, content_span) == 24);
    assert!(offset_of!(TwigQueryMatch, has_content_span) == 40);
    assert!(offset_of!(TwigQueryMatch, kind) == 48);

    assert!(size_of::<TwigChange>() == 32);
    assert!(offset_of!(TwigChange, old_span) == 0);
    assert!(offset_of!(TwigChange, new_span) == 16);

    assert!(size_of::<TwigFlatNode>() == 144);
    assert!(offset_of!(TwigFlatNode, id) == 0);
    assert!(offset_of!(TwigFlatNode, parent) == 4);
    assert!(offset_of!(TwigFlatNode, first_child) == 8);
    assert!(offset_of!(TwigFlatNode, next_sibling) == 12);
    assert!(offset_of!(TwigFlatNode, span) == 16);
    assert!(offset_of!(TwigFlatNode, content_span) == 32);
    assert!(offset_of!(TwigFlatNode, has_content_span) == 48);
    assert!(offset_of!(TwigFlatNode, level) == 52);
    assert!(offset_of!(TwigFlatNode, kind) == 56);
    assert!(offset_of!(TwigFlatNode, text_ptr) == 64);
    assert!(offset_of!(TwigFlatNode, text_len) == 72);
    assert!(offset_of!(TwigFlatNode, destination_ptr) == 80);
    assert!(offset_of!(TwigFlatNode, destination_len) == 88);
    assert!(offset_of!(TwigFlatNode, head) == 96);
    assert!(offset_of!(TwigFlatNode, alignment) == 100);
    assert!(offset_of!(TwigFlatNode, name_ptr) == 104);
    assert!(offset_of!(TwigFlatNode, name_len) == 112);
    assert!(offset_of!(TwigFlatNode, attrs_ptr) == 120);
    assert!(offset_of!(TwigFlatNode, attrs_len) == 128);
    assert!(offset_of!(TwigFlatNode, directive_form) == 136);

    assert!(size_of::<TwigKeyVal>() == 32);
    assert!(offset_of!(TwigKeyVal, key) == 0);
    assert!(offset_of!(TwigKeyVal, key_len) == 8);
    assert!(offset_of!(TwigKeyVal, value) == 16);
    assert!(offset_of!(TwigKeyVal, value_len) == 24);
};

#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TwigStatus(pub c_int);

#[allow(dead_code)]
impl TwigStatus {
    pub const OK: c_int = 0;
    pub const INVALID_ARGUMENT: c_int = 1;
    pub const PARSE_ERROR: c_int = 2;
    pub const OUT_OF_MEMORY: c_int = 3;
    pub const UNSUPPORTED_FORMAT: c_int = 4;
    pub const NOT_FOUND: c_int = 5;
    pub const AMBIGUOUS: c_int = 6;
    pub const NOT_EDITABLE: c_int = 7;
    pub const EDIT_CONFLICT: c_int = 8;
    pub const UNSAFE_METADATA: c_int = 9;
    pub const INTERNAL_ERROR: c_int = 255;
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TwigFormat {
    Djot = 1,
    Markdown = 2,
    Xml = 3,
    Html = 4,
}

/// Markdown extension flags for the `md_flags` bitmask of `twig_parse_ext` and
/// `twig_editor_create_ext`.
pub const TWIG_MD_DIRECTIVES: u32 = 1 << 0;
pub const TWIG_MD_MATH: u32 = 1 << 1;
pub const TWIG_MD_HTML_ELEMENTS: u32 = 1 << 2;

pub enum TwigDocument {}

pub enum TwigEditor {}

pub enum TwigBuilder {}

/// 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.
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct TwigKeyVal {
    pub key: *const u8,
    pub key_len: usize,
    pub value: *const u8,
    pub value_len: usize,
}

/// C ABI mirror of Zig's `TwigSpan` — a byte range `[start, end)`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TwigSpan {
    pub start: usize,
    pub end: usize,
}

/// 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).
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct TwigQueryMatch {
    pub node_id: u32,
    pub span: TwigSpan,
    pub content_span: TwigSpan,
    pub has_content_span: c_int,
    pub kind: *const c_char,
}

/// The sentinel `node_id` for "no such node" in a [`TwigFlatNode`] link field.
pub const TWIG_NO_NODE: u32 = u32::MAX;

/// 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).
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct TwigChange {
    pub old_span: TwigSpan,
    pub new_span: TwigSpan,
}

/// 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` [`TwigKeyVal`]s (NULL/0 when the node has no attributes). Both
/// borrow the current parse's payloads with the same lifetime as `text_ptr`.
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct TwigFlatNode {
    pub id: u32,
    pub parent: u32,
    pub first_child: u32,
    pub next_sibling: u32,
    pub span: TwigSpan,
    pub content_span: TwigSpan,
    pub has_content_span: c_int,
    pub level: u32,
    pub kind: *const c_char,
    pub text_ptr: *const u8,
    pub text_len: usize,
    pub destination_ptr: *const u8,
    pub destination_len: usize,
    pub head: c_int,
    pub alignment: c_int,
    pub name_ptr: *const u8,
    pub name_len: usize,
    pub attrs_ptr: *const TwigKeyVal,
    pub attrs_len: usize,
    pub directive_form: c_int,
}

/// `TwigFlatNode::head` for a node that is neither a `row` nor a `cell`.
pub const TWIG_HEAD_NONE: c_int = -1;

/// `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.
#[allow(dead_code)]
pub const TWIG_ALIGN_NONE: c_int = -1;
pub const TWIG_ALIGN_DEFAULT: c_int = 0;
pub const TWIG_ALIGN_LEFT: c_int = 1;
pub const TWIG_ALIGN_RIGHT: c_int = 2;
pub const TWIG_ALIGN_CENTER: c_int = 3;

/// `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.
#[allow(dead_code)]
pub const TWIG_DIRECTIVE_NONE: c_int = -1;
pub const TWIG_DIRECTIVE_TEXT: c_int = 0;
pub const TWIG_DIRECTIVE_LEAF: c_int = 1;
pub const TWIG_DIRECTIVE_CONTAINER: c_int = 2;

// `op` codes for `twig_editor_table_edit` — mirror of `TwigTableOp` in twig.h.
pub const TWIG_TABLE_INSERT_ROW: c_int = 0;
pub const TWIG_TABLE_DELETE_ROW: c_int = 1;
pub const TWIG_TABLE_INSERT_COLUMN: c_int = 2;
pub const TWIG_TABLE_DELETE_COLUMN: c_int = 3;
pub const TWIG_TABLE_SET_ALIGNMENT: c_int = 4;
pub const TWIG_TABLE_MOVE_ROW: c_int = 5;
pub const TWIG_TABLE_MOVE_COLUMN: c_int = 6;

unsafe extern "C" {
    pub fn twig_abi_version() -> u32;
    pub fn twig_version() -> u32;
    pub fn twig_version_string() -> *const c_char;
    pub fn twig_parse(
        input: *const u8,
        input_len: usize,
        format: c_int,
        out_doc: *mut *mut TwigDocument,
    ) -> TwigStatus;
    pub fn twig_parse_ext(
        input: *const u8,
        input_len: usize,
        format: c_int,
        md_flags: u32,
        out_doc: *mut *mut TwigDocument,
    ) -> TwigStatus;
    pub fn twig_document_destroy(doc: *mut TwigDocument);
    pub fn twig_document_render_html(
        doc: *mut TwigDocument,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_document_serialize(
        doc: *mut TwigDocument,
        format: c_int,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_document_ast_json(
        doc: *mut TwigDocument,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_document_query(
        doc: *mut TwigDocument,
        selector: *const u8,
        selector_len: usize,
        out_ptr: *mut *const TwigQueryMatch,
        out_len: *mut usize,
    ) -> TwigStatus;

    pub fn twig_editor_create(
        input: *const u8,
        input_len: usize,
        format: c_int,
        out_editor: *mut *mut TwigEditor,
    ) -> TwigStatus;
    pub fn twig_editor_create_ext(
        input: *const u8,
        input_len: usize,
        format: c_int,
        md_flags: u32,
        out_editor: *mut *mut TwigEditor,
    ) -> TwigStatus;
    pub fn twig_editor_destroy(editor: *mut TwigEditor);
    pub fn twig_editor_replace(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
        text: *const u8,
        text_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_replace_content(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
        text: *const u8,
        text_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_insert_before(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
        text: *const u8,
        text_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_insert_after(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
        text: *const u8,
        text_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_insert_child(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
        child_index: usize,
        text: *const u8,
        text_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_delete(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_delete_smart(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_unwrap(
        editor: *mut TwigEditor,
        locator: *const u8,
        locator_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_filter(
        editor: *mut TwigEditor,
        drop: *const u8,
        drop_len: usize,
        keep: *const u8,
        keep_len: usize,
        unwrap_kept: c_int,
    ) -> TwigStatus;
    pub fn twig_editor_source(
        editor: *mut TwigEditor,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_ast_json(
        editor: *mut TwigEditor,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_query(
        editor: *mut TwigEditor,
        selector: *const u8,
        selector_len: usize,
        out_ptr: *mut *const TwigQueryMatch,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_edit_range(
        editor: *mut TwigEditor,
        start: usize,
        end: usize,
        text: *const u8,
        text_len: usize,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_last_change(
        editor: *mut TwigEditor,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_undo(editor: *mut TwigEditor, out_change: *mut TwigChange) -> TwigStatus;
    pub fn twig_editor_redo(editor: *mut TwigEditor, out_change: *mut TwigChange) -> TwigStatus;
    pub fn twig_editor_coalesce_last(editor: *mut TwigEditor) -> TwigStatus;
    pub fn twig_editor_revision(editor: *mut TwigEditor) -> u64;
    pub fn twig_editor_dirty_range(editor: *mut TwigEditor, out_span: *mut TwigSpan)
        -> TwigStatus;
    pub fn twig_editor_clear_dirty(editor: *mut TwigEditor) -> TwigStatus;
    pub fn twig_editor_set_caret_blob(
        editor: *mut TwigEditor,
        blob_ptr: *const u8,
        blob_len: usize,
    ) -> TwigStatus;
    pub fn twig_editor_caret_blob(
        editor: *mut TwigEditor,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_nodes(
        editor: *mut TwigEditor,
        out_ptr: *mut *const TwigFlatNode,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_child_spans(
        editor: *mut TwigEditor,
        node_id: u32,
        out_ptr: *mut *const TwigQueryMatch,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_subtree(
        editor: *mut TwigEditor,
        node_id: u32,
        out_ptr: *mut *const TwigFlatNode,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_node_at(
        editor: *mut TwigEditor,
        offset: usize,
        out_match: *mut TwigQueryMatch,
    ) -> TwigStatus;
    pub fn twig_editor_nodes_at(
        editor: *mut TwigEditor,
        offset: usize,
        out_ptr: *mut *const TwigQueryMatch,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_editor_wrap_range(
        editor: *mut TwigEditor,
        start: usize,
        end: usize,
        kind: c_int,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_toggle_inline(
        editor: *mut TwigEditor,
        start: usize,
        end: usize,
        kind: c_int,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_set_block(
        editor: *mut TwigEditor,
        offset: usize,
        block_kind: c_int,
        level: u32,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_toggle_block_container(
        editor: *mut TwigEditor,
        start: usize,
        end: usize,
        container_kind: c_int,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_renumber_ordered_lists(
        editor: *mut TwigEditor,
        offset: usize,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_table_edit(
        editor: *mut TwigEditor,
        offset: usize,
        op: c_int,
        arg: c_int,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_insert_link(
        editor: *mut TwigEditor,
        start: usize,
        end: usize,
        destination: *const u8,
        destination_len: usize,
        out_change: *mut TwigChange,
    ) -> TwigStatus;
    pub fn twig_editor_insert_image(
        editor: *mut TwigEditor,
        start: usize,
        end: usize,
        destination: *const u8,
        destination_len: usize,
        out_change: *mut TwigChange,
    ) -> TwigStatus;

    pub fn twig_editor_insert_literal(
        editor: *mut TwigEditor,
        offset: usize,
        text: *const u8,
        text_len: usize,
        out_change: *mut TwigChange,
    ) -> TwigStatus;

    pub fn twig_editor_insert_line_break(
        editor: *mut TwigEditor,
        offset: usize,
        out_change: *mut TwigChange,
    ) -> TwigStatus;

    pub fn twig_builder_create(out_builder: *mut *mut TwigBuilder) -> TwigStatus;
    pub fn twig_builder_destroy(builder: *mut TwigBuilder);
    pub fn twig_builder_add(builder: *mut TwigBuilder, kind: c_int, out_id: *mut u32) -> TwigStatus;
    pub fn twig_builder_add_text(
        builder: *mut TwigBuilder,
        kind: c_int,
        text: *const u8,
        text_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_heading(builder: *mut TwigBuilder, level: u32, out_id: *mut u32) -> TwigStatus;
    pub fn twig_builder_add_code_block(
        builder: *mut TwigBuilder,
        lang: *const u8,
        lang_len: usize,
        has_lang: c_int,
        text: *const u8,
        text_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_raw_block(
        builder: *mut TwigBuilder,
        format: *const u8,
        format_len: usize,
        text: *const u8,
        text_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_metadata(
        builder: *mut TwigBuilder,
        lang: *const u8,
        lang_len: usize,
        text: *const u8,
        text_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_raw_inline(
        builder: *mut TwigBuilder,
        format: *const u8,
        format_len: usize,
        text: *const u8,
        text_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_smart_punctuation(
        builder: *mut TwigBuilder,
        punct_kind: c_int,
        text: *const u8,
        text_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_link(
        builder: *mut TwigBuilder,
        destination: *const u8,
        destination_len: usize,
        has_destination: c_int,
        reference: *const u8,
        reference_len: usize,
        has_reference: c_int,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_image(
        builder: *mut TwigBuilder,
        destination: *const u8,
        destination_len: usize,
        has_destination: c_int,
        reference: *const u8,
        reference_len: usize,
        has_reference: c_int,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_directive(
        builder: *mut TwigBuilder,
        form: c_int,
        name: *const u8,
        name_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_element(
        builder: *mut TwigBuilder,
        name: *const u8,
        name_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_processing_instruction(
        builder: *mut TwigBuilder,
        target: *const u8,
        target_len: usize,
        data: *const u8,
        data_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_footnote(
        builder: *mut TwigBuilder,
        label: *const u8,
        label_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_reference(
        builder: *mut TwigBuilder,
        label: *const u8,
        label_len: usize,
        destination: *const u8,
        destination_len: usize,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_bullet_list(
        builder: *mut TwigBuilder,
        style: c_int,
        tight: c_int,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_ordered_list(
        builder: *mut TwigBuilder,
        numbering: c_int,
        delim: c_int,
        tight: c_int,
        start: u32,
        has_start: c_int,
        out_id: *mut u32,
    ) -> TwigStatus;
    pub fn twig_builder_add_task_list(builder: *mut TwigBuilder, tight: c_int, out_id: *mut u32) -> TwigStatus;
    pub fn twig_builder_add_task_list_item(builder: *mut TwigBuilder, checked: c_int, out_id: *mut u32) -> TwigStatus;
    pub fn twig_builder_add_row(builder: *mut TwigBuilder, head: c_int, out_id: *mut u32) -> TwigStatus;
    pub fn twig_builder_add_cell(builder: *mut TwigBuilder, head: c_int, alignment: c_int, out_id: *mut u32) -> TwigStatus;
    pub fn twig_builder_set_children(
        builder: *mut TwigBuilder,
        parent: u32,
        ids: *const u32,
        ids_len: usize,
    ) -> TwigStatus;
    pub fn twig_builder_set_attrs(
        builder: *mut TwigBuilder,
        id: u32,
        kvs: *const TwigKeyVal,
        kvs_len: usize,
    ) -> TwigStatus;
    pub fn twig_builder_render_html(
        builder: *mut TwigBuilder,
        root: u32,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_builder_serialize(
        builder: *mut TwigBuilder,
        root: u32,
        format: c_int,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_builder_ast_json(
        builder: *mut TwigBuilder,
        root: u32,
        out_ptr: *mut *const u8,
        out_len: *mut usize,
    ) -> TwigStatus;
    pub fn twig_builder_query(
        builder: *mut TwigBuilder,
        root: u32,
        selector: *const u8,
        selector_len: usize,
        out_ptr: *mut *const TwigQueryMatch,
        out_len: *mut usize,
    ) -> TwigStatus;
}