Skip to main content

ad_plugins/
passthrough.rs

1//! Generic passthrough plugin processor.
2//!
3//! Used as a stub for plugin types that are not yet fully implemented
4//! but need to appear in the OPI with correct metadata.
5
6use ad_core::ndarray::NDArray;
7use ad_core::ndarray_pool::NDArrayPool;
8use ad_core::plugin::runtime::{NDPluginProcess, ProcessResult};
9
10/// A no-op plugin processor that passes arrays through unchanged.
11pub struct PassthroughProcessor {
12    plugin_type: String,
13}
14
15impl PassthroughProcessor {
16    pub fn new(plugin_type: &str) -> Self {
17        Self {
18            plugin_type: plugin_type.to_string(),
19        }
20    }
21}
22
23impl NDPluginProcess for PassthroughProcessor {
24    fn plugin_type(&self) -> &str {
25        &self.plugin_type
26    }
27
28    fn process_array(&mut self, _array: &NDArray, _pool: &NDArrayPool) -> ProcessResult {
29        ProcessResult::empty()
30    }
31}
32
33#[cfg(test)]
34mod tests {
35    use super::*;
36
37    #[test]
38    fn test_passthrough_plugin_type() {
39        let p = PassthroughProcessor::new("NDPluginAttribute");
40        assert_eq!(p.plugin_type(), "NDPluginAttribute");
41    }
42}