File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 7
7
#![ deny( missing_docs) ]
8
8
9
9
use std:: collections:: HashSet ;
10
+ use std:: sync:: Arc ;
10
11
11
12
use serde:: Deserialize ;
12
13
use serde_json:: Value ;
@@ -37,7 +38,7 @@ pub type ValidatorFn = dyn Fn(&App, &[&str]) -> anyhow::Result<()>;
37
38
#[ derive( Debug , Clone ) ]
38
39
pub struct App {
39
40
id : String ,
40
- locked : LockedApp ,
41
+ locked : Arc < LockedApp > ,
41
42
}
42
43
43
44
impl App {
@@ -46,7 +47,7 @@ impl App {
46
47
pub fn new ( id : impl Into < String > , locked : LockedApp ) -> Self {
47
48
Self {
48
49
id : id. into ( ) ,
49
- locked,
50
+ locked : Arc :: new ( locked ) ,
50
51
}
51
52
}
52
53
@@ -170,7 +171,7 @@ impl App {
170
171
/// Scrubs the locked app to only contain the given list of components
171
172
/// Introspects the LockedApp to find and selectively retain the triggers that correspond to those components
172
173
fn retain_components (
173
- mut self ,
174
+ self ,
174
175
retained_components : & [ & str ] ,
175
176
validators : & [ & ValidatorFn ] ,
176
177
) -> Result < LockedApp > {
@@ -187,11 +188,10 @@ impl App {
187
188
_ => None ,
188
189
} )
189
190
. collect ( ) ;
190
- self . locked
191
- . components
192
- . retain ( |c| component_ids. contains ( & c. id ) ) ;
193
- self . locked . triggers . retain ( |t| trigger_ids. contains ( & t. id ) ) ;
194
- Ok ( self . locked )
191
+ let mut locked = Arc :: unwrap_or_clone ( self . locked ) ;
192
+ locked. components . retain ( |c| component_ids. contains ( & c. id ) ) ;
193
+ locked. triggers . retain ( |t| trigger_ids. contains ( & t. id ) ) ;
194
+ Ok ( locked)
195
195
}
196
196
197
197
/// Validates that all components specified to be retained actually exist in the app
You can’t perform that action at this time.
0 commit comments