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 customizeable 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

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() };

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() };

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, and the standard retry policy.

Set the standard retry policy’s configuration.

Adjust a standard retry client with the given policy configuration.

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.

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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