Skip to main content

uni_plugin/adapter_common/
mod.rs

1//! Shared helpers reused by every loader adapter crate.
2//!
3//! Each of `uni-plugin-wasm`, `uni-plugin-extism`, `uni-plugin-pyo3`,
4//! `uni-plugin-rhai`, and `uni-plugin-custom` previously reimplemented
5//! Arrow type mapping, single-row `RecordBatch` construction, and a
6//! manifest JSON round-trip on the `Loader::load` path. This module
7//! hosts the consolidated versions.
8//!
9//! # Submodules
10//!
11//! - [`arrow_types`] — `ArgType` → `DataType` and wire-name → `DataType`
12//!   mapping shared by every loader. Replaces four duplicated copies of
13//!   `argtype_arrow` and two copies of `arrow_name_to_dt` /
14//!   `arrow_name_to_datatype`.
15//! - [`batch_builder`] — single-row `RecordBatch` + one-item
16//!   `SendableRecordBatchStream` builders.
17//!
18//! Pool factory unification is **not** part of this module — the wasm
19//! loader unifies its three internal factories via a crate-local
20//! `WasmInstanceFactory` trait, and the extism loader keeps its single
21//! factory. Pulling the factory shape into `uni-plugin` would require
22//! the trait to be parameterized over wasmtime / extism types, which
23//! would in turn force feature-gated re-exports here. Per §1.1's
24//! "ship what unifies cleanly, leave the rest" guidance, generic pool
25//! unification is deferred.
26//!
27//! The manifest JSON round-trip is removed by adding a `prepare_parsed`
28//! entry point to each loader (`Loader::prepare_parsed(manifest, grants)`)
29//! and routing `Loader::load` through it; the public
30//! `Loader::prepare(json_bytes, grants)` is preserved for test and
31//! external use.
32//!
33//! # Stability
34//!
35//! Helpers exported here are considered loader-internal — they live in
36//! `uni-plugin` so the dependency graph stays acyclic, not because
37//! out-of-tree code is expected to call them.
38
39// Rust guideline compliant
40
41pub mod arrow_types;
42pub mod batch_builder;