1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
use ;
use crateOperationShape;
use crateContainsOperation;
use ;
/// Filters the application of an inner [`Plugin`] using a predicate over the
/// [`ServiceShape::Operations`](crate::service::ServiceShape::Operations).
///
/// This contrasts with [`Scoped`](crate::plugin::Scoped) which can be used to selectively apply a [`Plugin`] to a
/// subset of operations at _compile time_.
///
/// See [`filter_by_operation`] for more details.
/// Filters the application of an inner [`Plugin`] using a predicate over the
/// [`ServiceShape::Operations`](crate::service::ServiceShape::Operations).
///
/// Users should prefer [`Scoped`](crate::plugin::Scoped) and fallback to [`filter_by_operation`]
/// in cases where [`Plugin`] application must be decided at runtime.
///
/// # Example
///
/// ```rust
/// use aws_smithy_http_server::plugin::filter_by_operation;
/// # use aws_smithy_http_server::{plugin::Plugin, operation::OperationShape, shape_id::ShapeId, service::{ServiceShape, ContainsOperation}};
/// # struct Pl;
/// # struct PokemonService;
/// # #[derive(PartialEq, Eq)]
/// # enum Operation { CheckHealth }
/// # impl ServiceShape for PokemonService { const VERSION: Option<&'static str> = None; const ID: ShapeId = ShapeId::new("", "", ""); type Operations = Operation; type Protocol = (); }
/// # impl ContainsOperation<CheckHealth> for PokemonService { const VALUE: Operation = Operation::CheckHealth; }
/// # struct CheckHealth;
/// # impl OperationShape for CheckHealth { const ID: ShapeId = ShapeId::new("", "", ""); type Input = (); type Output = (); type Error = (); }
/// # impl Plugin<PokemonService, CheckHealth, ()> for Pl { type Output = (); fn apply(&self, input: ()) -> Self::Output { input }}
/// # let plugin = Pl;
/// # let svc = ();
/// // Prevents `plugin` from being applied to the `CheckHealth` operation.
/// let filtered_plugin = filter_by_operation(plugin, |name| name != Operation::CheckHealth);
/// let new_operation = filtered_plugin.apply(svc);
/// ```