@@ -2,6 +2,8 @@ use std::path::Path;
2
2
3
3
use glob_match:: glob_match;
4
4
use indexmap:: IndexMap ;
5
+ use serde:: Deserialize ;
6
+ use serde:: Serialize ;
5
7
6
8
use super :: parcel_config:: PluginNode ;
7
9
@@ -25,15 +27,15 @@ use super::parcel_config::PluginNode;
25
27
/// });
26
28
/// ```
27
29
///
28
- #[ derive( Debug , Default , PartialEq ) ]
29
- pub struct PipelineMap {
30
+ #[ derive( Debug , Default , Deserialize , PartialEq , Serialize ) ]
31
+ pub struct PipelineMap (
30
32
/// Maps patterns to a series of plugins, called pipelines
31
- map : IndexMap < String , Vec < PluginNode > > ,
32
- }
33
+ IndexMap < String , Vec < PluginNode > > ,
34
+ ) ;
33
35
34
36
impl PipelineMap {
35
37
pub fn new ( map : IndexMap < String , Vec < PluginNode > > ) -> Self {
36
- Self { map }
38
+ Self ( map)
37
39
}
38
40
39
41
/// Finds pipelines contained by a pattern that match the given file path and named pipeline
@@ -74,7 +76,7 @@ impl PipelineMap {
74
76
// If a pipeline is requested, a the glob needs to match exactly
75
77
if let Some ( pipeline) = named_pipeline {
76
78
let exact_match = self
77
- . map
79
+ . 0
78
80
. iter ( )
79
81
. find ( |( pattern, _) | is_match ( pattern, path, basename, pipeline. as_ref ( ) ) ) ;
80
82
@@ -85,7 +87,7 @@ impl PipelineMap {
85
87
}
86
88
}
87
89
88
- for ( pattern, pipelines) in self . map . iter ( ) {
90
+ for ( pattern, pipelines) in self . 0 . iter ( ) {
89
91
if is_match ( & pattern, path, basename, "" ) {
90
92
matches. extend ( pipelines. iter ( ) . cloned ( ) ) ;
91
93
}
@@ -97,15 +99,12 @@ impl PipelineMap {
97
99
pub fn contains_named_pipeline ( & self , pipeline : impl AsRef < str > ) -> bool {
98
100
let named_pipeline = format ! ( "{}:" , pipeline. as_ref( ) ) ;
99
101
100
- self
101
- . map
102
- . keys ( )
103
- . any ( |glob| glob. starts_with ( & named_pipeline) )
102
+ self . 0 . keys ( ) . any ( |glob| glob. starts_with ( & named_pipeline) )
104
103
}
105
104
106
105
pub fn named_pipelines ( & self ) -> Vec < & str > {
107
106
self
108
- . map
107
+ . 0
109
108
. keys ( )
110
109
. filter_map ( |glob| glob. split_once ( ':' ) . map ( |g| g. 0 ) )
111
110
. collect ( )
0 commit comments