pub struct SharedServiceAdapter<T>(/* private fields */);Expand description
Adapter to use a tower::Service as a rama::Service,
sharing the service between each request it has to serve.
Note that:
- you should use
ServiceAdapterin case you do not want it to be shared, and prefer it to beCloned instead, which is anyway the more “normal” scenario; - you are required to use the
LayerServiceAdapterfor tower layer services, which will automatically be the case if you useLayerAdapterto wrap atower::Layer.
§Halting
This adapter assumes that a service will always become ready eventually,
as it will call poll_ready until ready prior to calling the tower::Service.
Please ensure that your tower::Service does not require a side-step to prevent such halting.
Implementations§
Sourcepub fn new(svc: T) -> Self
pub fn new(svc: T) -> Self
Adapt a shared tower::Service into a rama::Service.
See SharedServiceAdapter for more information.
Trait Implementations§
Source§type Response = <T as Service<Request>>::Response
type Response = <T as Service<Request>>::Response
The type of response returned by the service.
Auto Trait Implementations§
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<S, StateIn, StateOut, RequestIn, RequestOut> RequestInspector<StateIn, RequestIn> for S
impl<S, StateIn, StateOut, RequestIn, RequestOut> RequestInspector<StateIn, RequestIn> for S
Source§type Error = <S as Service<StateIn, RequestIn>>::Error
type Error = <S as Service<StateIn, RequestIn>>::Error
The type of error returned by the service.
type RequestOut = RequestOut
type StateOut = StateOut
Source§fn inspect_request(
&self,
ctx: Context<StateIn>,
req: RequestIn,
) -> impl Future<Output = Result<(Context<<S as RequestInspector<StateIn, RequestIn>>::StateOut>, <S as RequestInspector<StateIn, RequestIn>>::RequestOut), <S as RequestInspector<StateIn, RequestIn>>::Error>> + Send
fn inspect_request( &self, ctx: Context<StateIn>, req: RequestIn, ) -> impl Future<Output = Result<(Context<<S as RequestInspector<StateIn, RequestIn>>::StateOut>, <S as RequestInspector<StateIn, RequestIn>>::RequestOut), <S as RequestInspector<StateIn, RequestIn>>::Error>> + Send
Inspect the request, modify it if needed or desired, and return it.