use crate::plugin::{HttpMarker, HttpPlugins, PluginStack};
use crate::{operation::OperationShape, plugin::Plugin};
use super::sensitivity::Sensitivity;
use super::InstrumentOperation;
#[derive(Debug)]
pub struct InstrumentPlugin;
impl<Ser, Op, T> Plugin<Ser, Op, T> for InstrumentPlugin
where
Op: OperationShape,
Op: Sensitivity,
{
type Output = InstrumentOperation<T, Op::RequestFmt, Op::ResponseFmt>;
fn apply(&self, input: T) -> Self::Output {
InstrumentOperation::new(input, Op::ID)
.request_fmt(Op::request_fmt())
.response_fmt(Op::response_fmt())
}
}
impl HttpMarker for InstrumentPlugin {}
pub trait InstrumentExt<CurrentPlugin> {
fn instrument(self) -> HttpPlugins<PluginStack<InstrumentPlugin, CurrentPlugin>>;
}
impl<CurrentPlugin> InstrumentExt<CurrentPlugin> for HttpPlugins<CurrentPlugin> {
fn instrument(self) -> HttpPlugins<PluginStack<InstrumentPlugin, CurrentPlugin>> {
self.push(InstrumentPlugin)
}
}