pub struct Exc<C, Req> { /* private fields */ }
Expand description
The core service wrapper of this crate, which implements
ExcService<T>
if the request type of the underlying
service implements Adaptor<T>
.
With the help of Exc
, we can use a single type to represent
all the services that an exchange can provide.
For example, let Exchange
be an api endpoint implementation of a exchange,
which implements [Service<R>
], where R
is the request type of the api endpoint.
Then Exc<Exchange, R>
will implement Service<SubscribeTickers>
and
Service<PlaceOrder>
, as long as R
implements both Adaptor<SubscribeTickers>
and Adaptor<PlaceOrder>
.
Implementations§
source§impl<C, Req> Exc<C, Req>
impl<C, Req> Exc<C, Req>
sourcepub fn into_inner(self) -> C
pub fn into_inner(self) -> C
Into the inner channel.
source§impl<C, Req> Exc<C, Req>where
Req: Request,
C: ExcService<Req>,
impl<C, Req> Exc<C, Req>where
Req: Request,
C: ExcService<Req>,
sourcepub fn new(service: C) -> Exc<C, Req>
pub fn new(service: C) -> Exc<C, Req>
Create from the given ExcService
.
sourcepub async fn request(
&mut self,
request: Req
) -> Result<<Req as Request>::Response, ExchangeError>
pub async fn request( &mut self, request: Req ) -> Result<<Req as Request>::Response, ExchangeError>
Make a request using the underlying channel directly.
sourcepub fn into_rate_limited(
self,
num: u64,
per: Duration
) -> Exc<RateLimit<IntoService<C, Req>>, Req>
pub fn into_rate_limited( self, num: u64, per: Duration ) -> Exc<RateLimit<IntoService<C, Req>>, Req>
Apply rate-limit layer to the channel.
sourcepub fn into_retry(
self,
max_duration: Duration
) -> Exc<Retry<Always, IntoService<C, Req>>, Req>
pub fn into_retry( self, max_duration: Duration ) -> Exc<Retry<Always, IntoService<C, Req>>, Req>
Apply retry layer to the channel.
sourcepub fn into_adapted<R>(self) -> Exc<Adapt<IntoService<C, Req>, Req, R>, R>
pub fn into_adapted<R>(self) -> Exc<Adapt<IntoService<C, Req>, Req, R>, R>
Adapt the request type of the underlying channel to the target type R
.
sourcepub fn into_layered<T, R>(
self,
layer: &T
) -> Exc<<T as Layer<IntoService<C, Req>>>::Service, R>where
T: Layer<IntoService<C, Req>>,
R: Request,
<T as Layer<IntoService<C, Req>>>::Service: ExcService<R>,
pub fn into_layered<T, R>(
self,
layer: &T
) -> Exc<<T as Layer<IntoService<C, Req>>>::Service, R>where
T: Layer<IntoService<C, Req>>,
R: Request,
<T as Layer<IntoService<C, Req>>>::Service: ExcService<R>,
Apply a layer to the underlying channel.
Trait Implementations§
source§impl<C, Req, R> Service<R> for Exc<C, Req>where
R: Request,
<R as Request>::Response: Send + 'static,
Req: Adaptor<R>,
C: ExcService<Req>,
<C as ExcService<Req>>::Future: Send + 'static,
impl<C, Req, R> Service<R> for Exc<C, Req>where
R: Request,
<R as Request>::Response: Send + 'static,
Req: Adaptor<R>,
C: ExcService<Req>,
<C as ExcService<Req>>::Future: Send + 'static,
§type Error = ExchangeError
type Error = ExchangeError
§type Future = Pin<Box<dyn Future<Output = Result<<Exc<C, Req> as Service<R>>::Response, <Exc<C, Req> as Service<R>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<Exc<C, Req> as Service<R>>::Response, <Exc<C, Req> as Service<R>>::Error>> + Send>>
Auto Trait Implementations§
impl<C, Req> RefUnwindSafe for Exc<C, Req>where
C: RefUnwindSafe,
impl<C, Req> Send for Exc<C, Req>where
C: Send,
impl<C, Req> Sync for Exc<C, Req>where
C: Sync,
impl<C, Req> Unpin for Exc<C, Req>where
C: Unpin,
impl<C, Req> UnwindSafe for Exc<C, Req>where
C: UnwindSafe,
Blanket Implementations§
source§impl<C, Req, R> AdaptService<Req, R> for C
impl<C, Req, R> AdaptService<Req, R> for C
§type AdaptedResponse = AndThen<<C as ExcService<Req>>::Future, fn(_: <Req as Request>::Response) -> Result<<R as Request>::Response, ExchangeError>>
type AdaptedResponse = AndThen<<C as ExcService<Req>>::Future, fn(_: <Req as Request>::Response) -> Result<<R as Request>::Response, ExchangeError>>
AdaptService::into_response
].source§fn adapt_from_request(&mut self, req: R) -> Result<Req, ExchangeError>
fn adapt_from_request(&mut self, req: R) -> Result<Req, ExchangeError>
source§fn adapt_into_response(
&mut self,
res: <C as ExcService<Req>>::Future
) -> <C as AdaptService<Req, R>>::AdaptedResponse
fn adapt_into_response( &mut self, res: <C as ExcService<Req>>::Future ) -> <C as AdaptService<Req, R>>::AdaptedResponse
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<S, R> ExcService<R> for S
impl<S, R> ExcService<R> for S
source§fn poll_ready(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), ExchangeError>>
fn poll_ready( &mut self, cx: &mut Context<'_> ) -> Poll<Result<(), ExchangeError>>
Service::poll_ready
] for more details.source§fn call(&mut self, req: R) -> <S as ExcService<R>>::Future
fn call(&mut self, req: R) -> <S as ExcService<R>>::Future
Service::call
] for more details.source§fn as_service(&mut self) -> AsService<'_, Self, R>where
Self: Sized,
fn as_service(&mut self) -> AsService<'_, Self, R>where
Self: Sized,
Service
].source§impl<S, R> ExcServiceExt<R> for Swhere
S: ExcService<R>,
R: Request,
impl<S, R> ExcServiceExt<R> for Swhere
S: ExcService<R>,
R: Request,
source§fn into_service(self) -> IntoService<Self, R>where
Self: Sized,
fn into_service(self) -> IntoService<Self, R>where
Self: Sized,
Service
].source§fn apply<L, R2>(self, layer: &L) -> <L as Layer<Self>>::Service
fn apply<L, R2>(self, layer: &L) -> <L as Layer<Self>>::Service
ExcService
.source§fn rate_limited(
self,
num: u64,
per: Duration
) -> RateLimit<IntoService<Self, R>>where
Self: Sized,
fn rate_limited(
self,
num: u64,
per: Duration
) -> RateLimit<IntoService<Self, R>>where
Self: Sized,
source§fn retry(self, max_duration: Duration) -> Retry<Always, IntoService<Self, R>>
fn retry(self, max_duration: Duration) -> Retry<Always, IntoService<Self, R>>
source§fn boxed(self) -> BoxExcService<R>
fn boxed(self) -> BoxExcService<R>
ExcService
.source§fn boxed_clone(&self) -> BoxCloneExcService<R>
fn boxed_clone(&self) -> BoxCloneExcService<R>
ExcService
with 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, R> IntoExc<R> for Swhere
S: Service<R, Response = <R as Request>::Response>,
<S as Service<R>>::Error: Into<ExchangeError>,
R: Request,
impl<S, R> IntoExc<R> for Swhere
S: Service<R, Response = <R as Request>::Response>,
<S as Service<R>>::Error: Into<ExchangeError>,
R: Request,
source§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>,
source§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>>
Ready
when the factory is able to create more services. Read moresource§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
source§impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
impl<T, Request> ServiceExt<Request> for Twhere
T: Service<Request> + ?Sized,
source§fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
source§fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
fn ready_and(&mut self) -> Ready<'_, Self, Request>where
Self: Sized,
ServiceExt::ready
method insteadsource§fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
fn ready_oneshot(self) -> ReadyOneshot<Self, Request>where
Self: Sized,
source§fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
fn oneshot(self, req: Request) -> Oneshot<Self, Request>where
Self: Sized,
Service
, calling with the providing request once it is ready.source§fn and_then<F>(self, f: F) -> AndThen<Self, F>
fn and_then<F>(self, f: F) -> AndThen<Self, F>
poll_ready
method. Read moresource§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 moresource§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 moresource§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