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,
Source§type Error = ExchangeError
type Error = ExchangeError
Source§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> Freeze for Exc<C, Req>where
C: Freeze,
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
Source§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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§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<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 moreSource§impl<M, S, Target, Request> MakeService<Target, Request> for M
impl<M, S, Target, Request> MakeService<Target, Request> for M
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 T
impl<T, Request> ServiceExt<Request> for T
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