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:
Bruce Guenter 2020-07-10 08:47:39 -06:00 committed by GitHub
parent b12a3e3ae9
commit 4316894422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -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>

View File

@ -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>