Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

C FFI API

Rudra Code provides C-compatible bindings via opaque handles.

Build

cd ffi/c
cargo build --release
# Output: target/release/libs1engine_c.{so,dylib,dll}

API

#include "s1engine.h"

// Create engine
S1Engine* engine = s1_engine_new();

// Open a document
S1Error* err = NULL;
S1Document* doc = s1_engine_open(engine, data, len, &err);

// Get text
S1String* text = s1_document_plain_text(doc);
printf("%s\n", s1_string_ptr(text));

// Export
S1Bytes* docx = s1_document_export(doc, "docx", &err);
// Use s1_bytes_data() and s1_bytes_len()

// Cleanup
s1_string_free(text);
s1_bytes_free(docx);
s1_document_free(doc);
s1_engine_free(engine);

Handle Types

TypeDescriptionFree Function
S1EngineEngine instances1_engine_free
S1DocumentOpen documents1_document_free
S1ErrorError messages1_error_free
S1StringUTF-8 strings1_string_free
S1BytesByte buffers1_bytes_free