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 77#![ deny( missing_docs) ]
88
99use std:: collections:: HashSet ;
10+ use std:: sync:: Arc ;
1011
1112use serde:: Deserialize ;
1213use serde_json:: Value ;
@@ -37,7 +38,7 @@ pub type ValidatorFn = dyn Fn(&App, &[&str]) -> anyhow::Result<()>;
3738#[ derive( Debug , Clone ) ]
3839pub struct App {
3940 id : String ,
40- locked : LockedApp ,
41+ locked : Arc < LockedApp > ,
4142}
4243
4344impl App {
@@ -46,7 +47,7 @@ impl App {
4647 pub fn new ( id : impl Into < String > , locked : LockedApp ) -> Self {
4748 Self {
4849 id : id. into ( ) ,
49- locked,
50+ locked : Arc :: new ( locked ) ,
5051 }
5152 }
5253
@@ -170,7 +171,7 @@ impl App {
170171 /// Scrubs the locked app to only contain the given list of components
171172 /// Introspects the LockedApp to find and selectively retain the triggers that correspond to those components
172173 fn retain_components (
173- mut self ,
174+ self ,
174175 retained_components : & [ & str ] ,
175176 validators : & [ & ValidatorFn ] ,
176177 ) -> Result < LockedApp > {
@@ -187,11 +188,10 @@ impl App {
187188 _ => None ,
188189 } )
189190 . 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)
195195 }
196196
197197 /// 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