iridis_file_ext/
plugin.rs

1//! This module contains the `FileExtPlugin` trait and its implementations.
2
3use std::path::PathBuf;
4
5use crate::prelude::{thirdparty::tokio::task::JoinHandle, *};
6
7/// This trait must be implemented in order to make a plugin compatible with the `iridis_file_ext` crate.
8pub trait FileExtPlugin: Send + Sync {
9    /// This function is called when the plugin is loaded.
10    #[allow(clippy::new_ret_no_self)]
11    fn new() -> JoinHandle<Result<Box<dyn FileExtPlugin>>>
12    where
13        Self: Sized;
14
15    /// This function is called when the plugin is loaded to determine which file extensions it supports.
16    fn target(&self) -> Vec<String>;
17
18    /// This function is called to load a `Node` from the plugin.
19    fn load(
20        &self,
21        path: PathBuf,
22
23        inputs: Inputs,
24        outputs: Outputs,
25        queries: Queries,
26        queryables: Queryables,
27        configuration: serde_yml::Value,
28    ) -> JoinHandle<Result<RuntimeNode>>;
29}
30
31/// This type is used to represent the return type of the `C` symbolic function that instantiates the plugin.
32pub type DynamicallyLinkedFileExtPluginInstance =
33    fn() -> JoinHandle<Result<Box<dyn FileExtPlugin>>>;