edgefirst-tflite-sys 0.8.0

Low-level FFI bindings for the TensorFlow Lite C API with runtime symbol loading
Documentation
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2025 Au-Zone Technologies. All Rights Reserved.

//! Low-level FFI bindings for the TensorFlow Lite C API.
//!
//! This crate provides raw, unsafe bindings generated by `bindgen` with
//! `--dynamic-loading`. Symbols are resolved at runtime via `libloading`.
//!
//! **Most users should depend on `edgefirst-tflite` instead**, which
//! provides a safe, ergonomic API on top of these bindings.
//!
//! # Library Discovery
//!
//! Use [`discovery::discover`] to automatically find and load the `TFLite`
//! shared library, or [`discovery::load`] to load from a specific path.
//!
//! # Delegate Extensions
//!
//! The [`hal_ffi`] module provides function pointer structs for the
//! HAL Delegate DMA-BUF API (the standard, delegate-agnostic interface).
//!
//! The [`vx_ffi`] module provides function pointer structs for the
//! legacy `VxDelegate` DMA-BUF and `CameraAdaptor` APIs. Both are loaded
//! at runtime from the delegate shared library.
//!
//! The [`xnnpack_ffi`] module provides function pointer structs for the
//! XNNPACK built-in delegate API, loaded from the main `TFLite` library.

// Suppress all clippy/rustc/rustdoc warnings for bindgen-generated code.
#[allow(
    clippy::all,
    clippy::pedantic,
    clippy::nursery,
    non_upper_case_globals,
    non_camel_case_types,
    non_snake_case,
    missing_debug_implementations,
    unreachable_pub,
    dead_code,
    rustdoc::bare_urls,
    rustdoc::broken_intra_doc_links
)]
mod ffi {
    include!("ffi.rs");

    impl tensorflowlite_c {
        /// Returns a reference to the underlying `libloading::Library`.
        ///
        /// This is an escape hatch for loading optional symbols (e.g.,
        /// XNNPACK) that live inside the main TFLite shared library rather
        /// than a separate delegate `.so`.
        #[must_use]
        pub fn library(&self) -> &::libloading::Library {
            &self.__library
        }
    }
}

pub use ffi::*;

/// Sentinel value for an unset `TfLiteBufferHandle` (`kTfLiteNullBufferHandle = -1`).
#[allow(non_upper_case_globals)]
pub const kTfLiteNullBufferHandle: TfLiteBufferHandle = -1;

pub mod discovery;
pub mod hal_ffi;
pub mod vx_ffi;
pub mod xnnpack_ffi;