Struct aws_smithy_client::Client [−][src]
pub struct Client<Connector = DynConnector, Middleware = DynMiddleware<Connector>, RetryPolicy = Standard> { /* fields omitted */ }
Expand description
Smithy service client.
The service client is customizable in a number of ways (see Builder
), but most customers
can stick with the standard constructor provided by Client::new
. It takes only a single
argument, which is the middleware that fills out the http::Request
for each higher-level
operation so that it can ultimately be sent to the remote host. The middleware is responsible
for filling in any request parameters that aren’t specified by the Smithy protocol definition,
such as those used for routing (like the URL), authentication, and authorization.
The middleware takes the form of a tower::Layer
that wraps the actual connection for each
request. The tower::Service
that the middleware produces must accept requests of the type
aws_smithy_http::operation::Request
and return responses of the type
http::Response<SdkBody>
, most likely by modifying the provided request in place, passing it
to the inner service, and then ultimately returning the inner service’s response.
With the hyper
feature enabled, you can construct a Client
directly from a
hyper::Client
using hyper_ext::Adapter::builder
. You can also enable the rustls
or native-tls
features to construct a Client against a standard HTTPS endpoint using Builder::rustls
and
Builder::native_tls
respectively.
Implementations
impl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<C> + Send + Sync + 'static,
R: NewRequestPolicy,
impl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<C> + Send + Sync + 'static,
R: NewRequestPolicy,
Erase the middleware type from the client type signature.
This makes the final client type easier to name, at the cost of a marginal increase in
runtime performance. See DynMiddleware
for details.
In practice, you’ll use this method once you’ve constructed a client to your liking:
use aws_smithy_client::{Builder, Client};
struct MyClient {
client: Client<aws_smithy_client::conns::Https>,
}
let client = Builder::new()
.https()
.middleware(tower::layer::util::Identity::new())
.build();
let client = MyClient { client: client.into_dyn_middleware() };
impl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<DynConnector> + Send + Sync + 'static,
R: NewRequestPolicy,
impl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<DynConnector> + Send + Sync + 'static,
R: NewRequestPolicy,
Erase the connector type from the client type signature.
This makes the final client type easier to name, at the cost of a marginal increase in
runtime performance. See DynConnector
for details.
In practice, you’ll use this method once you’ve constructed a client to your liking:
use aws_smithy_client::{Builder, Client};
struct MyClient {
client: Client<aws_smithy_client::DynConnector, MyMiddleware>,
}
let client = Builder::new()
.https()
.middleware(tower::layer::util::Identity::new())
.build();
let client = MyClient { client: client.into_dyn_connector() };
Erase the connector and middleware types from the client type signature.
This makes the final client type easier to name, at the cost of a marginal increase in
runtime performance. See DynConnector
and DynMiddleware
for details.
Note that if you’re using the standard retry mechanism, retry::Standard
, DynClient<R>
is equivalent to Client
with no type arguments.
In practice, you’ll use this method once you’ve constructed a client to your liking:
use aws_smithy_client::{Builder, Client};
struct MyClient {
client: aws_smithy_client::Client,
}
let client = Builder::new()
.https()
.middleware(tower::layer::util::Identity::new())
.build();
let client = MyClient { client: client.into_dyn() };
impl<M> Client<DynConnector, M> where
M: Default,
M: SmithyMiddleware<DynConnector> + Send + Sync + 'static,
impl<M> Client<DynConnector, M> where
M: Default,
M: SmithyMiddleware<DynConnector> + Send + Sync + 'static,
Create a Smithy client that uses HTTPS and the standard retry policy over the default middleware implementation.
For convenience, this constructor type-erases the concrete TLS connector backend used using
dynamic dispatch. This comes at a slight runtime performance cost. See
DynConnector
for details. To avoid that overhead, use
Builder::rustls
or Builder::native_tls
instead.
Create a Smithy client that the given connector, a middleware default, the standard
retry policy, and the default_async_sleep
sleep implementation.
Set the standard retry policy’s configuration.
Adjust a standard retry client with the given policy configuration.
Set the client’s timeout configuration.
Set the client’s timeout configuration.
Set the AsyncSleep
function that the client will use to create things like timeout futures.
Set the AsyncSleep
function that the client will use to create things like timeout futures.
impl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<C>,
R: NewRequestPolicy,
impl<C, M, R> Client<C, M, R> where
C: SmithyConnector,
M: SmithyMiddleware<C>,
R: NewRequestPolicy,
pub async fn call<O, T, E, Retry>(
&self,
input: Operation<O, Retry>
) -> Result<T, SdkError<E>> where
O: Send + Sync,
Retry: Send + Sync,
R::Policy: SmithyRetryPolicy<O, T, E, Retry>,
Parsed<<M as SmithyMiddleware<C>>::Service, O, Retry>: Service<Operation<O, Retry>, Response = SdkSuccess<T>, Error = SdkError<E>> + Clone,
pub async fn call<O, T, E, Retry>(
&self,
input: Operation<O, Retry>
) -> Result<T, SdkError<E>> where
O: Send + Sync,
Retry: Send + Sync,
R::Policy: SmithyRetryPolicy<O, T, E, Retry>,
Parsed<<M as SmithyMiddleware<C>>::Service, O, Retry>: Service<Operation<O, Retry>, Response = SdkSuccess<T>, Error = SdkError<E>> + Clone,
Dispatch this request to the network
For ergonomics, this does not include the raw response for successful responses. To
access the raw response use call_raw
.
pub async fn call_raw<O, T, E, Retry>(
&self,
input: Operation<O, Retry>
) -> Result<SdkSuccess<T>, SdkError<E>> where
O: Send + Sync,
Retry: Send + Sync,
R::Policy: SmithyRetryPolicy<O, T, E, Retry>,
Parsed<<M as SmithyMiddleware<C>>::Service, O, Retry>: Service<Operation<O, Retry>, Response = SdkSuccess<T>, Error = SdkError<E>> + Clone,
pub async fn call_raw<O, T, E, Retry>(
&self,
input: Operation<O, Retry>
) -> Result<SdkSuccess<T>, SdkError<E>> where
O: Send + Sync,
Retry: Send + Sync,
R::Policy: SmithyRetryPolicy<O, T, E, Retry>,
Parsed<<M as SmithyMiddleware<C>>::Service, O, Retry>: Service<Operation<O, Retry>, Response = SdkSuccess<T>, Error = SdkError<E>> + Clone,
Dispatch this request to the network
The returned result contains the raw HTTP response which can be useful for debugging or implementing unsupported features.
Trait Implementations
Auto Trait Implementations
impl<Connector = DynConnector, Middleware = DynMiddleware<Connector>, RetryPolicy = Standard> !RefUnwindSafe for Client<Connector, Middleware, RetryPolicy>
impl<Connector, Middleware, RetryPolicy> Send for Client<Connector, Middleware, RetryPolicy> where
Connector: Send,
Middleware: Send,
RetryPolicy: Send,
impl<Connector, Middleware, RetryPolicy> Sync for Client<Connector, Middleware, RetryPolicy> where
Connector: Sync,
Middleware: Sync,
RetryPolicy: Sync,
impl<Connector, Middleware, RetryPolicy> Unpin for Client<Connector, Middleware, RetryPolicy> where
Connector: Unpin,
Middleware: Unpin,
RetryPolicy: Unpin,
impl<Connector = DynConnector, Middleware = DynMiddleware<Connector>, RetryPolicy = Standard> !UnwindSafe for Client<Connector, Middleware, RetryPolicy>
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more