pub struct ServiceAdapter<T>(/* private fields */);Expand description
Adapter to use a tower::Service as a rama::Service,
cloning the servicer for each request it has to serve.
Note that:
- you should use
SharedServiceAdapterin case you do not want it to beCloned, but instead shared across serve calls (we’ll wrap your tower service with aMutex); - 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§
Source§impl<T: Clone + Send + Sync + 'static> ServiceAdapter<T>
impl<T: Clone + Send + Sync + 'static> ServiceAdapter<T>
Sourcepub fn new(svc: T) -> Self
pub fn new(svc: T) -> Self
Adapt a Clone/call tower::Service into a rama::Service.
See ServiceAdapter for more information.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consume itself to return the inner tower::Service back.
Trait Implementations§
Source§impl<T: Clone> Clone for ServiceAdapter<T>
impl<T: Clone> Clone for ServiceAdapter<T>
Source§fn clone(&self) -> ServiceAdapter<T>
fn clone(&self) -> ServiceAdapter<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for ServiceAdapter<T>
impl<T: Debug> Debug for ServiceAdapter<T>
Source§impl<T, State, Request> Service<State, Request> for ServiceAdapter<T>
impl<T, State, Request> Service<State, Request> for ServiceAdapter<T>
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§
impl<T> Freeze for ServiceAdapter<T>where
T: Freeze,
impl<T> RefUnwindSafe for ServiceAdapter<T>where
T: RefUnwindSafe,
impl<T> Send for ServiceAdapter<T>where
T: Send,
impl<T> Sync for ServiceAdapter<T>where
T: Sync,
impl<T> Unpin for ServiceAdapter<T>where
T: Unpin,
impl<T> UnwindSafe for ServiceAdapter<T>where
T: UnwindSafe,
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.