pub(crate) struct MakeServiceWithConnectInfo<S> {
pub(crate) inner: S,
}Expand description
Turns an already-Clone service — limited_make_service’s
[ConcurrencyLimit]-wrapped router — into a [tower::Service]
axum::serve and axum_server can both drive per accepted connection,
the same way [tower::make::Shared] does, but also carrying a
[ConnectInfo] extension for the connection’s peer address, which
crate::rate_limit::caller_key reads by default.
axum’s own Router::into_make_service_with_connect_info cannot stand
in for this: it is only defined on a bare [Router], not on whatever
type wrapping one in a [tower::Layer] produces, and
MAX_CONCURRENT_REQUESTS’s own doc explains why that wrapping must
happen exactly once, here, rather than as a Router::layer — this type
exists so that requirement and per-connection ConnectInfo are not a
choice between one or the other.
Fields§
§inner: SImplementations§
Source§impl<S> MakeServiceWithConnectInfo<S>
impl<S> MakeServiceWithConnectInfo<S>
Trait Implementations§
Source§impl<S: Clone> Clone for MakeServiceWithConnectInfo<S>
impl<S: Clone> Clone for MakeServiceWithConnectInfo<S>
Source§fn clone(&self) -> MakeServiceWithConnectInfo<S>
fn clone(&self) -> MakeServiceWithConnectInfo<S>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<S, T> Service<T> for MakeServiceWithConnectInfo<S>where
S: Clone,
SocketAddr: Connected<T>,
impl<S, T> Service<T> for MakeServiceWithConnectInfo<S>where
S: Clone,
SocketAddr: Connected<T>,
Source§type Response = ConnectInfoService<S>
type Response = ConnectInfoService<S>
Source§type Error = Infallible
type Error = Infallible
Source§type Future = Ready<Result<<MakeServiceWithConnectInfo<S> as Service<T>>::Response, <MakeServiceWithConnectInfo<S> as Service<T>>::Error>>
type Future = Ready<Result<<MakeServiceWithConnectInfo<S> as Service<T>>::Response, <MakeServiceWithConnectInfo<S> as Service<T>>::Error>>
Auto Trait Implementations§
impl<S> Freeze for MakeServiceWithConnectInfo<S>where
S: Freeze,
impl<S> RefUnwindSafe for MakeServiceWithConnectInfo<S>where
S: RefUnwindSafe,
impl<S> Send for MakeServiceWithConnectInfo<S>where
S: Send,
impl<S> Sync for MakeServiceWithConnectInfo<S>where
S: Sync,
impl<S> Unpin for MakeServiceWithConnectInfo<S>where
S: Unpin,
impl<S> UnsafeUnpin for MakeServiceWithConnectInfo<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for MakeServiceWithConnectInfo<S>where
S: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
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>
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 more§impl<M, S, Target, Request> MakeService<Target, Request> for Mwhere
M: Service<Target, Response = S>,
S: Service<Request>,
impl<M, S, Target, Request> MakeService<Target, Request> for Mwhere
M: Service<Target, Response = S>,
S: Service<Request>,
§fn poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
Poll::Ready when the factory is able to create more services. Read more§fn make_service(
&mut self,
target: Target,
) -> <M as MakeService<Target, Request>>::Future
fn make_service( &mut self, target: Target, ) -> <M as MakeService<Target, Request>>::Future
§fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
fn into_service(self) -> IntoService<Self, Request>where
Self: Sized,
§fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
fn as_service(&mut self) -> AsService<'_, Self, Request>where
Self: Sized,
§impl<T, S, B, E, F, Target, Request> MakeService<Target, Request> for Twhere
T: Service<Target, Response = S, Error = E, Future = F>,
S: Service<Request, Response = Response<B>> + Send + Clone + 'static,
<S as Service<Request>>::Error: Into<Box<dyn Error + Send + Sync>>,
<S as Service<Request>>::Future: Send + 'static,
B: Body + Send + 'static,
<B as Body>::Data: Send + 'static,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync>>,
E: Into<Box<dyn Error + Send + Sync>>,
F: Future<Output = Result<S, E>>,
impl<T, S, B, E, F, Target, Request> MakeService<Target, Request> for Twhere
T: Service<Target, Response = S, Error = E, Future = F>,
S: Service<Request, Response = Response<B>> + Send + Clone + 'static,
<S as Service<Request>>::Error: Into<Box<dyn Error + Send + Sync>>,
<S as Service<Request>>::Future: Send + 'static,
B: Body + Send + 'static,
<B as Body>::Data: Send + 'static,
<B as Body>::Error: Into<Box<dyn Error + Send + Sync>>,
E: Into<Box<dyn Error + Send + Sync>>,
F: Future<Output = Result<S, E>>,
type Service = S
type Body = B
type BodyData = <B as Body>::Data
type BodyError = <B as Body>::Error
type Error = <S as Service<Request>>::Error
type Future = <S as Service<Request>>::Future
type MakeError = E
type MakeFuture = F
fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <T as MakeService<Target, Request>>::MakeError>>
fn make_service( &mut self, target: Target, ) -> <T as MakeService<Target, Request>>::MakeFuture
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
impl<S, R> ServiceExt<R> for Swhere
S: Service<R>,
§fn into_make_service(self) -> IntoMakeService<S>
fn into_make_service(self) -> IntoMakeService<S>
MakeService, that is a [Service] whose
response is another service. Read more§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<S, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<S, C>
MakeService, that will store C’s
associated ConnectInfo in a request extension such that ConnectInfo
can extract it. Read more§fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
fn handle_error<F, T>(self, f: F) -> HandleError<Self, F, T>
HandleError, that will handle errors
by converting them into responses. Read more§impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service, calling it with the provided request once it is ready.§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready method. Read more§fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
fn map_response<F, Response>(self, f: F) -> MapResponse<Self, F>
poll_ready method. Read more§fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
fn map_err<F, Error>(self, f: F) -> MapErr<Self, F>
poll_ready method. Read more§fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
fn map_result<F, Response, Error>(self, f: F) -> MapResult<Self, F>
Result<Self::Response, Self::Error>)
to a different value, regardless of whether the future succeeds or
fails. Read more