rama_http/layer/retry/
layer.rsuse super::Retry;
use rama_core::Layer;
use std::fmt;
pub struct RetryLayer<P> {
policy: P,
}
impl<P: fmt::Debug> fmt::Debug for RetryLayer<P> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RetryLayer")
.field("policy", &self.policy)
.finish()
}
}
impl<P: Clone> Clone for RetryLayer<P> {
fn clone(&self) -> Self {
Self {
policy: self.policy.clone(),
}
}
}
impl<P> RetryLayer<P> {
pub const fn new(policy: P) -> Self {
RetryLayer { policy }
}
}
impl<P, S> Layer<S> for RetryLayer<P>
where
P: Clone,
{
type Service = Retry<P, S>;
fn layer(&self, service: S) -> Self::Service {
let policy = self.policy.clone();
Retry::new(policy, service)
}
}