Skip to content

Add C/C++ FFI Interface to Enable Native Integration of feedtui #12

@muk2

Description

@muk2

feedtui is currently designed as a standalone Rust terminal application built with ratatui. To broaden adoption and enable integration into native systems workflows, it would be valuable to expose a stable C-compatible FFI layer so that C++ users can:
• Build feedtui from source and invoke it programmatically
• Embed or launch the TUI from existing C++ applications
• Distribute feedtui as a shared/static library usable outside the Rust ecosystem

This would allow non-Rust users to leverage the TUI without needing to understand Rust internals.

Proposed Solution

Introduce a C ABI boundary that exposes a minimal, stable interface for interacting with feedtui.

  1. Rust-side FFI Layer
    • Add a dedicated ffi module/crate
    • Use #[no_mangle] extern "C" functions
    • Expose lifecycle-style APIs, for example:
    • feedtui_init(config)
    • feedtui_run()
    • feedtui_shutdown()

  2. Build Artifacts
    • Support building:
    • libfeedtui.so / libfeedtui.dylib
    • Optional static library
    • Provide a cargo build --features ffi path

  3. C/C++ Headers
    • Generate or maintain a C header (feedtui.h)
    • Ensure:
    • Opaque handles instead of Rust types
    • Explicit ownership and memory rules
    • No Rust panics cross the FFI boundary

  4. Example Usage
    • Provide:
    • Minimal C++ example (main.cpp)
    • Build instructions using cmake or clang++
    • Demonstrate:
    • Initializing the app
    • Running the TUI
    • Clean shutdown

Open Questions
• Should the FFI be gated behind a feature flag?
• Do we want to guarantee ABI stability across minor versions?
• Should we support launching feedtui as a library and a CLI?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions