pub struct Client { /* private fields */ }Expand description
A default batteries included transport client.
This provides a fully featured http client based on hyper::Client
and tower services.
§Multiplexing requests
Sending a request on a client requires a &mut self and thus can only send
one request in flight. This is intentional and is required to follow the Service
contract from the tower library which this client implementation is built on
top of.
tower itself has a concept of poll_ready which is the main mechanism to apply
back pressure. poll_ready takes a &mut self and when it returns Poll::Ready
we know the Service is able to accept only one request before we must poll_ready
again. Due to this fact any async fn that wants to poll for readiness and submit
the request must have a &mut self reference.
To work around this and to ease the use of the client, Channel provides a
Clone implementation that is cheap. This is because at the very top level
the client is backed by a tower_buffer::Buffer which runs the connection
in a background task and provides a mpsc client interface. Due to this
cloning the Channel type is cheap and encouraged.
Implementations§
Source§impl Client
impl Client
Sourcepub fn from_static(s: &'static str) -> ApiNode
pub fn from_static(s: &'static str) -> ApiNode
Create an Endpoint from a static string.
Client::from_static("http://api-1.testnet2.xpxsirius.io:3000");Create an Endpoint from shared bytes.
Client::from_shared("http://api-1.testnet2.xpxsirius.io:3000");Source§impl Client
impl Client
Sourcepub fn account_api(&self) -> Box<AccountRoutes>
pub fn account_api(&self) -> Box<AccountRoutes>
Get Account ApiClient routes.
Sourcepub fn chain_api(&self) -> Box<ChainRoutes>
pub fn chain_api(&self) -> Box<ChainRoutes>
Get Chain ApiClient routes.
Sourcepub fn node_api(&self) -> Box<NodeRoutes>
pub fn node_api(&self) -> Box<NodeRoutes>
Get Node ApiClient routes.
Sourcepub fn network_api(&self) -> Box<NetworkRoutes>
pub fn network_api(&self) -> Box<NetworkRoutes>
Get Network ApiClient routes.
Sourcepub fn mosaic_api(&self) -> Box<MosaicRoutes>
pub fn mosaic_api(&self) -> Box<MosaicRoutes>
Get Mosaic ApiClient routes.
Sourcepub fn namespace_api(&self) -> Box<NamespaceRoutes>
pub fn namespace_api(&self) -> Box<NamespaceRoutes>
Get Namespace ApiClient routes.
Sourcepub fn transaction_api(&self) -> Box<TransactionRoutes>
pub fn transaction_api(&self) -> Box<TransactionRoutes>
Get Transaction ApiClient routes.
Sourcepub fn resolver_api(&self) -> Box<ResolverRoutes>
pub fn resolver_api(&self) -> Box<ResolverRoutes>
Get Resolver ApiClient routes.
Sourcepub fn metadata_v2_api(&self) -> Box<MetadataV2Routes>
pub fn metadata_v2_api(&self) -> Box<MetadataV2Routes>
Get MetadataV2 ApiClient routes.
Trait Implementations§
Source§impl Service<Request<ReplayBody>> for Client
impl Service<Request<ReplayBody>> for Client
Source§type Future = Pin<Box<dyn Future<Output = Result<<Client as Service<Request<ReplayBody>>>::Response, <Client as Service<Request<ReplayBody>>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<Client as Service<Request<ReplayBody>>>::Response, <Client as Service<Request<ReplayBody>>>::Error>> + Send>>
Auto Trait Implementations§
impl !Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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
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<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