Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Barber committed Oct 11, 2022
1 parent a04c7c4 commit 6340483
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http-server/src/plugin/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ pub struct FilterByOperationName<Inner, F> {

impl<Inner, F> FilterByOperationName<Inner, F> {
/// Creates a new [`FilterByOperationName`].
pub fn new(inner: Inner, predicate: F) -> Self {
pub(crate) fn new(inner: Inner, predicate: F) -> Self {
Self { inner, predicate }
}
}

impl<P, Op, S, L, Inner, F> Plugin<P, Op, S, L> for FilterByOperationName<Inner, F>
where
F: Fn(&'static str) -> bool,
F: Fn(&str) -> bool,
Inner: Plugin<P, Op, S, L>,
Op: OperationShape,
{
Expand Down
9 changes: 5 additions & 4 deletions rust-runtime/aws-smithy-http-server/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,19 @@ pub trait PluginExt<P, Op, S, L>: Plugin<P, Op, S, L> {
/// ```rust
/// # use aws_smithy_http_server::{plugin::{Plugin, PluginExt}, operation::{Operation, OperationShape}};
/// # struct Pl;
/// # struct Op;
/// # impl OperationShape for Op { const NAME: &'static str = ""; type Input = (); type Output = (); type Error = (); }
/// # impl Plugin<(), Op, (), ()> for Pl { type Service = (); type Layer = (); fn map(&self, input: Operation<(), ()>) -> Operation<(), ()> { input }}
/// # struct CheckHealth;
/// # impl OperationShape for CheckHealth { const NAME: &'static str = ""; type Input = (); type Output = (); type Error = (); }
/// # impl Plugin<(), CheckHealth, (), ()> for Pl { type Service = (); type Layer = (); fn map(&self, input: Operation<(), ()>) -> Operation<(), ()> { input }}
/// # let plugin = Pl;
/// # let operation = Operation { inner: (), layer: () };
/// // Prevents `plugin` from being applied to the `CheckHealth` operation.
/// let filtered_plugin = plugin.filter_by_operation_name(|name| name != "com.aws.example#CheckHealth");
/// let filtered_plugin = plugin.filter_by_operation_name(|name| name != CheckHealth::NAME);
/// let new_operation = filtered_plugin.map(operation);
/// ```
fn filter_by_operation_name<F>(self, predicate: F) -> FilterByOperationName<Self, F>
where
Self: Sized,
F: Fn(&str) -> bool,
{
FilterByOperationName::new(self, predicate)
}
Expand Down

0 comments on commit 6340483

Please sign in to comment.