Add get_ref functions to more service layers (#463)
* Implement get_ref, get_mut, and into_inner for Retry * Implement get_ref, get_mut, and into_inner for Timeout
This commit is contained in:
parent
b12a3e3ae9
commit
4316894422
|
@ -31,6 +31,21 @@ impl<P, S> Retry<P, S> {
|
|||
pub fn new(policy: P, service: S) -> Self {
|
||||
Retry { policy, service }
|
||||
}
|
||||
|
||||
/// Get a reference to the inner service
|
||||
pub fn get_ref(&self) -> &S {
|
||||
&self.service
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the inner service
|
||||
pub fn get_mut(&mut self) -> &mut S {
|
||||
&mut self.service
|
||||
}
|
||||
|
||||
/// Consume `self`, returning the inner service
|
||||
pub fn into_inner(self) -> S {
|
||||
self.service
|
||||
}
|
||||
}
|
||||
|
||||
impl<P, S, Request> Service<Request> for Retry<P, S>
|
||||
|
|
|
@ -28,6 +28,21 @@ impl<T> Timeout<T> {
|
|||
pub fn new(inner: T, timeout: Duration) -> Self {
|
||||
Timeout { inner, timeout }
|
||||
}
|
||||
|
||||
/// Get a reference to the inner service
|
||||
pub fn get_ref(&self) -> &T {
|
||||
&self.inner
|
||||
}
|
||||
|
||||
/// Get a mutable reference to the inner service
|
||||
pub fn get_mut(&mut self) -> &mut T {
|
||||
&mut self.inner
|
||||
}
|
||||
|
||||
/// Consume `self`, returning the inner service
|
||||
pub fn into_inner(self) -> T {
|
||||
self.inner
|
||||
}
|
||||
}
|
||||
|
||||
impl<S, Request> Service<Request> for Timeout<S>
|
||||
|
|
Loading…
Reference in New Issue