pub struct Client<Connector = DynConnector, Middleware = DynMiddleware<Connector>, RetryPolicy = Standard> { /* private fields */ }
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_connector and Builder::native_tls_connector respectively.

Implementations§

source§

impl<C, M, R> Client<C, M, R>where C: SmithyConnector, M: SmithyMiddleware<C> + Send + Sync + 'static, R: NewRequestPolicy,

source

pub fn into_dyn_middleware(self) -> Client<C, DynMiddleware<C>, R>

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

impl<C, M, R> Client<C, M, R>where C: SmithyConnector, M: SmithyMiddleware<DynConnector> + Send + Sync + 'static, R: NewRequestPolicy,

source

pub fn into_dyn_connector(self) -> Client<DynConnector, M, R>

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

pub fn into_dyn(self) -> DynClient<R>

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

impl Client<(), (), ()>

source

pub fn builder() -> Builder

Returns a client builder

source§

impl<C, M> Client<C, M>where M: Default,

source

pub fn new(connector: C) -> Self

Create a Smithy client from the given connector, a middleware default, the standard retry policy, and the default_async_sleep sleep implementation.

source§

impl<C, M, R> Client<C, M, R>where C: SmithyConnector, M: SmithyMiddleware<C>, R: NewRequestPolicy,

source

pub async fn call<O, T, E, Retry>( &self, op: Operation<O, Retry> ) -> Result<T, SdkError<E>>where O: Send + Sync, E: Error + Send + Sync + 'static, Retry: Send + Sync + ClassifyRetry<SdkSuccess<T>, SdkError<E>>, 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.

source

pub async fn call_raw<O, T, E, Retry>( &self, op: Operation<O, Retry> ) -> Result<SdkSuccess<T>, SdkError<E>>where O: Send + Sync, E: Error + Send + Sync + 'static, Retry: Send + Sync + ClassifyRetry<SdkSuccess<T>, SdkError<E>>, 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§

source§

impl<Connector: Debug, Middleware: Debug, RetryPolicy: Debug> Debug for Client<Connector, Middleware, RetryPolicy>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more