tailwind_rs_postcss/
plugin_loader.rs1use crate::ast::CSSNode;
6use crate::error::Result;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct PluginConfig {
12 pub name: String,
13 pub version: Option<String>,
14 pub options: serde_json::Value,
15}
16
17impl PluginConfig {
18 pub fn requires_js(&self) -> bool {
20 false
22 }
23}
24
25#[derive(Debug)]
27pub struct PluginLoader;
28
29#[derive(Debug)]
31pub enum PluginResult {
32 Native(NativePlugin),
33 JavaScript(JSPlugin),
34}
35
36#[derive(Debug)]
38pub struct NativePlugin;
39
40impl NativePlugin {
41 pub fn transform(&self, ast: CSSNode) -> Result<CSSNode> {
42 Ok(ast)
43 }
44}
45
46#[derive(Debug)]
48pub struct JSPlugin {
49 pub name: String,
50}
51
52impl PluginLoader {
53 pub fn new() -> Self {
55 Self
56 }
57
58 pub async fn load_plugin(&self, _config: &PluginConfig) -> Result<PluginResult> {
60 Ok(PluginResult::Native(NativePlugin))
62 }
63}
64
65#[cfg(test)]
66mod tests {
67 use super::*;
68
69 #[test]
70 fn test_plugin_loader_creation() {
71 let loader = PluginLoader::new();
72 assert!(true); }
74}