Skip to main content

FfiBinding

Trait FfiBinding 

Source
pub trait FfiBinding: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn source_lang(&self) -> &'static str;
    fn target_lang(&self) -> &'static str;
    fn detect_in_build_file(&self, path: &Path, content: &str) -> Option<String>;
    fn consumer_extensions(&self) -> &[&'static str];
    fn matches_import(
        &self,
        import_module: &str,
        import_name: &str,
        known_module: &str,
    ) -> bool;
}
Expand description

Trait for FFI binding detection.

Each binding type (PyO3, wasm-bindgen, etc.) implements this trait to describe how to detect it in a project.

Required Methods§

Source

fn name(&self) -> &'static str

Unique identifier for this binding type (e.g., “pyo3”, “wasm-bindgen”)

Source

fn source_lang(&self) -> &'static str

Source language for this binding (e.g., “rust”)

Source

fn target_lang(&self) -> &'static str

Target language for this binding (e.g., “python”)

Source

fn detect_in_build_file(&self, path: &Path, content: &str) -> Option<String>

Check if a build file (e.g., Cargo.toml) indicates this binding is used. Returns the module name if detected.

Source

fn consumer_extensions(&self) -> &[&'static str]

File extensions that may contain imports of this binding’s modules.

Source

fn matches_import( &self, import_module: &str, import_name: &str, known_module: &str, ) -> bool

Check if an import line references a module from this binding. module_name is the crate/package name (with underscores for Rust).

Implementors§