Skip to main content

reifydb_sdk/transform/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4pub mod context;
5pub mod exports;
6pub mod wrapper;
7
8use std::collections::HashMap;
9
10use reifydb_type::value::Value;
11
12use crate::{error::Result, operator::change::BorrowedColumns, transform::context::FFITransformContext};
13
14pub trait FFITransformMetadata {
15	/// Transform name (must be unique within a library)
16	const NAME: &'static str;
17	/// API version for FFI compatibility (must match host's CURRENT_API)
18	const API: u32;
19	/// Semantic version of the transform (e.g., "1.0.0")
20	const VERSION: &'static str;
21	/// Human-readable description of the transform
22	const DESCRIPTION: &'static str;
23}
24
25pub trait FFITransform: 'static {
26	fn new(config: &HashMap<String, Value>) -> Result<Self>
27	where
28		Self: Sized;
29
30	/// Apply the transform.
31	///
32	/// `input` borrows native column storage; do not retain pointers past
33	/// return. Emit output via `ctx.builder()` -- typically a single
34	/// `emit_insert`, mirroring `FFIOperator::pull`.
35	fn transform(&mut self, ctx: &mut FFITransformContext, input: BorrowedColumns<'_>) -> Result<()>;
36}
37
38pub trait FFITransformWithMetadata: FFITransform + FFITransformMetadata {}
39impl<T> FFITransformWithMetadata for T where T: FFITransform + FFITransformMetadata {}