Struct aws_smithy_http_server::plugin::ModelPlugins
source · pub struct ModelPlugins<P>(/* private fields */);
Expand description
A wrapper struct for composing model plugins.
It operates identically to HttpPlugins
; see its documentation.
Implementations§
source§impl ModelPlugins<IdentityPlugin>
impl ModelPlugins<IdentityPlugin>
sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty ModelPlugins
.
You can use ModelPlugins::push
to add plugins to it.
source§impl<P> ModelPlugins<P>
impl<P> ModelPlugins<P>
sourcepub fn push<NewPlugin: ModelMarker>(
self,
new_plugin: NewPlugin,
) -> ModelPlugins<PluginStack<NewPlugin, P>>
pub fn push<NewPlugin: ModelMarker>( self, new_plugin: NewPlugin, ) -> ModelPlugins<PluginStack<NewPlugin, P>>
Apply a new model plugin after the ones that have already been registered.
use aws_smithy_http_server::plugin::ModelPlugins;
let model_plugins = ModelPlugins::new().push(LoggingPlugin).push(MetricsPlugin);
The plugins’ runtime logic is executed in registration order.
In our example above, LoggingPlugin
would run first, while MetricsPlugin
is executed last.
§Implementation notes
Plugins are applied to the underlying Service
in opposite order compared
to their registration order.
As an example:
ⓘ
#[derive(Debug)]
pub struct PrintPlugin;
impl<Ser, Op, S> Plugin<Ser, Op, T> for PrintPlugin
// [...]
{
// [...]
fn apply(&self, inner: T) -> Self::Service {
PrintService {
inner,
service_id: Ser::ID,
operation_id: Op::ID
}
}
}
sourcepub fn layer<L>(self, layer: L) -> ModelPlugins<PluginStack<LayerPlugin<L>, P>>
pub fn layer<L>(self, layer: L) -> ModelPlugins<PluginStack<LayerPlugin<L>, P>>
Applies a single [tower::Layer
] to all operations before they are deserialized.
Trait Implementations§
source§impl<P: Debug> Debug for ModelPlugins<P>
impl<P: Debug> Debug for ModelPlugins<P>
source§impl Default for ModelPlugins<IdentityPlugin>
impl Default for ModelPlugins<IdentityPlugin>
source§impl<Ser, Op, T, InnerPlugin> Plugin<Ser, Op, T> for ModelPlugins<InnerPlugin>where
InnerPlugin: Plugin<Ser, Op, T>,
impl<Ser, Op, T, InnerPlugin> Plugin<Ser, Op, T> for ModelPlugins<InnerPlugin>where
InnerPlugin: Plugin<Ser, Op, T>,
impl<InnerPlugin> ModelMarker for ModelPlugins<InnerPlugin>where
InnerPlugin: ModelMarker,
Auto Trait Implementations§
impl<P> Freeze for ModelPlugins<P>where
P: Freeze,
impl<P> RefUnwindSafe for ModelPlugins<P>where
P: RefUnwindSafe,
impl<P> Send for ModelPlugins<P>where
P: Send,
impl<P> Sync for ModelPlugins<P>where
P: Sync,
impl<P> Unpin for ModelPlugins<P>where
P: Unpin,
impl<P> UnwindSafe for ModelPlugins<P>where
P: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.