Struct aws_sdk_s3::client::Builder [−][src]
Expand description
A builder that provides more customization options when constructing a Client
.
To start, call Builder::new
. Then, chain the method calls to configure the Builder
.
When configured to your liking, call Builder::build
. The individual methods have additional
documentation.
Implementations
Construct a new builder.
This will
You will likely want to , as it does not specify a connector or middleware. It uses the standard retry mechanism.
Specify the connector for the eventual client to use.
The connector dictates how requests are turned into responses. Normally, this would entail sending the request to some kind of remote server, but in certain settings it’s useful to be able to use a custom connector instead, such as to mock the network for tests.
If you just want to specify a function from request to response instead, use
Builder::map_connector
.
pub fn connector_fn<F, FF>(self, map: F) -> Builder<ServiceFn<F>, M, R> where
F: Fn(Request<SdkBody>) -> FF + Send,
FF: Future<Output = Result<Response<SdkBody>, ConnectorError>>,
ServiceFn<F>: SmithyConnector,
pub fn connector_fn<F, FF>(self, map: F) -> Builder<ServiceFn<F>, M, R> where
F: Fn(Request<SdkBody>) -> FF + Send,
FF: Future<Output = Result<Response<SdkBody>, ConnectorError>>,
ServiceFn<F>: SmithyConnector,
Use a function that directly maps each request to a response as a connector.
use aws_smithy_client::Builder;
use aws_smithy_http::body::SdkBody;
let client = Builder::new()
.middleware(..)
.connector_fn(|req: http::Request<SdkBody>| {
async move {
Ok(http::Response::new(SdkBody::empty()))
}
})
.build();
Specify the middleware for the eventual client ot use.
The middleware adjusts requests before they are dispatched to the connector. It 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.
If your requests are already ready to be sent and need no adjustment, you can use
tower::layer::util::Identity
as your middleware.
pub fn middleware_fn<F>(self, map: F) -> Builder<C, MapRequestLayer<F>, R> where
F: 'static + Fn(Request) -> Request + Clone + Send + Sync,
pub fn middleware_fn<F>(self, map: F) -> Builder<C, MapRequestLayer<F>, R> where
F: 'static + Fn(Request) -> Request + Clone + Send + Sync,
Use a function-like middleware that directly maps each request.
use aws_smithy_client::Builder;
use aws_smithy_http::body::SdkBody;
let client = Builder::new()
.https()
.middleware_fn(|req: aws_smithy_http::operation::Request| {
req
})
.build();
Specify the retry policy for the eventual client to use.
By default, the Smithy client uses a standard retry policy that works well in most
settings. You can use this method to override that policy with a custom one. A new policy
instance will be instantiated for each request using retry::NewRequestPolicy
. Each
policy instance must implement tower::retry::Policy
.
If you just want to modify the policy configuration for the standard retry policy, use
Builder::set_retry_config
.
Set the standard retry policy’s configuration.
Use a connector that wraps the current connector.
Use a middleware that wraps the current middleware.
impl<C, M, R> Builder<C, M, R> where
C: SmithyConnector,
M: 'static + SmithyMiddleware<DynConnector> + Send + Sync,
R: NewRequestPolicy,
impl<C, M, R> Builder<C, M, R> where
C: SmithyConnector,
M: 'static + SmithyMiddleware<DynConnector> + Send + Sync,
R: NewRequestPolicy,
Build a type-erased Smithy service Client
.
Note that if you’re using the standard retry mechanism, retry::Standard
, DynClient<R>
is equivalent to Client
with no type arguments.
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_dyn();
let client = MyClient { client };
pub fn rustls(
self
) -> Builder<HyperAdapter<HttpsConnector<HttpConnector<GaiResolver>>>, M, R>
pub fn rustls(
self
) -> Builder<HyperAdapter<HttpsConnector<HttpConnector<GaiResolver>>>, M, R>
Connect to the service over HTTPS using Rustls.
Connect to the service over HTTPS using Rustls.
This is exactly equivalent to Builder::rustls
. If you instead wish to use native_tls
,
use Builder::native_tls
.
Trait Implementations
Auto Trait Implementations
impl<C, M, R> RefUnwindSafe for Builder<C, M, R> where
C: RefUnwindSafe,
M: RefUnwindSafe,
R: RefUnwindSafe,
impl<C, M, R> UnwindSafe for Builder<C, M, R> where
C: UnwindSafe,
M: UnwindSafe,
R: UnwindSafe,
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