@@ -31,7 +31,7 @@ pub const OCI_IMAGE_DIGEST_KEY: MetadataKey = MetadataKey::new("oci_image_digest
31
31
32
32
/// Validation function type for ensuring that applications meet requirements
33
33
/// even with components filtered out.
34
- pub type ValidatorFn = dyn Fn ( & App , & [ String ] ) -> anyhow:: Result < ( ) > ;
34
+ pub type ValidatorFn = dyn Fn ( & App , & [ & str ] ) -> anyhow:: Result < ( ) > ;
35
35
36
36
/// An `App` holds loaded configuration for a Spin application.
37
37
#[ derive( Debug , Clone ) ]
@@ -171,7 +171,7 @@ impl App {
171
171
/// Introspects the LockedApp to find and selectively retain the triggers that correspond to those components
172
172
fn retain_components (
173
173
mut self ,
174
- retained_components : & [ String ] ,
174
+ retained_components : & [ & str ] ,
175
175
validators : & [ & ValidatorFn ] ,
176
176
) -> Result < LockedApp > {
177
177
self . validate_retained_components_exist ( retained_components) ?;
@@ -181,7 +181,7 @@ impl App {
181
181
let ( component_ids, trigger_ids) : ( HashSet < String > , HashSet < String > ) = self
182
182
. triggers ( )
183
183
. filter_map ( |t| match t. component ( ) {
184
- Ok ( comp) if retained_components. contains ( & comp. id ( ) . to_string ( ) ) => {
184
+ Ok ( comp) if retained_components. contains ( & comp. id ( ) ) => {
185
185
Some ( ( comp. id ( ) . to_owned ( ) , t. id ( ) . to_owned ( ) ) )
186
186
}
187
187
_ => None ,
@@ -195,13 +195,13 @@ impl App {
195
195
}
196
196
197
197
/// Validates that all components specified to be retained actually exist in the app
198
- fn validate_retained_components_exist ( & self , retained_components : & [ String ] ) -> Result < ( ) > {
198
+ fn validate_retained_components_exist ( & self , retained_components : & [ & str ] ) -> Result < ( ) > {
199
199
let app_components = self
200
200
. components ( )
201
201
. map ( |c| c. id ( ) . to_string ( ) )
202
202
. collect :: < HashSet < _ > > ( ) ;
203
203
for c in retained_components {
204
- if !app_components. contains ( c) {
204
+ if !app_components. contains ( * c) {
205
205
return Err ( Error :: ValidationError ( anyhow:: anyhow!(
206
206
"Specified component \" {c}\" not found in application"
207
207
) ) ) ;
@@ -320,7 +320,7 @@ struct CommonTriggerConfig {
320
320
/// Introspects the LockedApp to find and selectively retain the triggers that correspond to those components
321
321
pub fn retain_components (
322
322
locked : LockedApp ,
323
- components : & [ String ] ,
323
+ components : & [ & str ] ,
324
324
validators : & [ & ValidatorFn ] ,
325
325
) -> Result < LockedApp > {
326
326
App :: new ( "unused" , locked) . retain_components ( components, validators)
@@ -332,7 +332,7 @@ mod test {
332
332
333
333
use super :: * ;
334
334
335
- fn does_nothing_validator ( _: & App , _: & [ String ] ) -> anyhow:: Result < ( ) > {
335
+ fn does_nothing_validator ( _: & App , _: & [ & str ] ) -> anyhow:: Result < ( ) > {
336
336
Ok ( ( ) )
337
337
}
338
338
@@ -351,12 +351,7 @@ mod test {
351
351
source = "does-not-exist.wasm"
352
352
} ;
353
353
let mut locked_app = build_locked_app ( & manifest) . await . unwrap ( ) ;
354
- locked_app = retain_components (
355
- locked_app,
356
- & [ "empty" . to_string ( ) ] ,
357
- & [ & does_nothing_validator] ,
358
- )
359
- . unwrap ( ) ;
354
+ locked_app = retain_components ( locked_app, & [ "empty" ] , & [ & does_nothing_validator] ) . unwrap ( ) ;
360
355
let components = locked_app
361
356
. components
362
357
. iter ( )
0 commit comments