mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 05:35:10 +00:00
Implement PluginChain
This commit is contained in:
@@ -7,5 +7,28 @@ pub enum PluginResult {
|
||||
}
|
||||
|
||||
pub trait Plugin {
|
||||
fn transform(item: &VfsItem) -> PluginResult;
|
||||
fn transform_file(&self, plugins: &PluginChain, vfs_item: &VfsItem) -> PluginResult;
|
||||
}
|
||||
|
||||
pub struct PluginChain {
|
||||
plugins: Vec<Box<Plugin + Send>>,
|
||||
}
|
||||
|
||||
impl PluginChain {
|
||||
pub fn new(plugins: Vec<Box<Plugin + Send>>) -> PluginChain {
|
||||
PluginChain {
|
||||
plugins,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn transform_file(&self, vfs_item: &VfsItem) -> Option<RbxItem> {
|
||||
for plugin in &self.plugins {
|
||||
match plugin.transform_file(self, vfs_item) {
|
||||
PluginResult::Value(rbx_item) => return rbx_item,
|
||||
PluginResult::Pass => {},
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user