Struct Builder

Source
pub struct Builder { /* private fields */ }
Expand description

Builder for creating a Config.

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Constructs a config builder.

Source

pub fn api_key(self, api_key: AuthApiKey) -> Self

Sets the API key that will be used by the client.

Source

pub fn set_api_key(&mut self, api_key: Option<AuthApiKey>) -> &mut Self

Sets the API key that will be used by the client.

Source

pub fn stage(self, stage: impl Into<String>) -> Self

The endpoint stage used to contruct the hostname.

Source

pub fn set_stage(&mut self, stage: Option<String>) -> &mut Self

The endpoint stage used to contruct the hostname.

Source

pub fn endpoint_resolver( self, endpoint_resolver: impl ResolveEndpoint<Params> + 'static, ) -> Self

Sets the endpoint resolver to use when making requests.

When unset, the client will used a generated endpoint resolver based on the endpoint resolution rules for stedi_sdk_client_guides.

§Examples
use aws_smithy_http::endpoint;
use stedi_sdk_client_guides::endpoint::{Params as EndpointParams, DefaultResolver};
/// Endpoint resolver which adds a prefix to the generated endpoint
struct PrefixResolver {
    base_resolver: DefaultResolver,
    prefix: String
}
impl endpoint::ResolveEndpoint<EndpointParams> for PrefixResolver {
  fn resolve_endpoint(&self, params: &EndpointParams) -> endpoint::Result {
       self.base_resolver
             .resolve_endpoint(params)
             .map(|ep|{
                  let url = ep.url().to_string();
                  ep.into_builder().url(format!("{}.{}", &self.prefix, url)).build()
              })
  }
}
let prefix_resolver = PrefixResolver {
    base_resolver: DefaultResolver::new(),
    prefix: "subdomain".to_string()
};
let config = stedi_sdk_client_guides::Config::builder().endpoint_resolver(prefix_resolver);
Source

pub fn set_endpoint_resolver( &mut self, endpoint_resolver: Option<Arc<dyn ResolveEndpoint<Params>>>, ) -> &mut Self

Sets the endpoint resolver to use when making requests.

When unset, the client will used a generated endpoint resolver based on the endpoint resolution rules for stedi_sdk_client_guides.

Source

pub fn retry_config(self, retry_config: RetryConfig) -> Self

Set the retry_config for the builder

§Examples
use stedi_sdk_client_guides::config::Config;
use stedi_sdk_client_guides::config::retry::RetryConfig;

let retry_config = RetryConfig::standard().with_max_attempts(5);
let config = Config::builder().retry_config(retry_config).build();
Source

pub fn set_retry_config( &mut self, retry_config: Option<RetryConfig>, ) -> &mut Self

Set the retry_config for the builder

§Examples
use stedi_sdk_client_guides::config::{Builder, Config};
use stedi_sdk_client_guides::config::retry::RetryConfig;

fn disable_retries(builder: &mut Builder) {
    let retry_config = RetryConfig::standard().with_max_attempts(1);
    builder.set_retry_config(Some(retry_config));
}

let mut builder = Config::builder();
disable_retries(&mut builder);
let config = builder.build();
Source

pub fn sleep_impl(self, sleep_impl: Arc<dyn AsyncSleep>) -> Self

Set the sleep_impl for the builder

§Examples
use stedi_sdk_client_guides::config::{AsyncSleep, Sleep, Config};

#[derive(Debug)]
pub struct ForeverSleep;

impl AsyncSleep for ForeverSleep {
    fn sleep(&self, duration: std::time::Duration) -> Sleep {
        Sleep::new(std::future::pending())
    }
}

let sleep_impl = std::sync::Arc::new(ForeverSleep);
let config = Config::builder().sleep_impl(sleep_impl).build();
Source

pub fn set_sleep_impl( &mut self, sleep_impl: Option<Arc<dyn AsyncSleep>>, ) -> &mut Self

Set the sleep_impl for the builder

§Examples
use stedi_sdk_client_guides::config::{AsyncSleep, Sleep, Builder, Config};

#[derive(Debug)]
pub struct ForeverSleep;

impl AsyncSleep for ForeverSleep {
    fn sleep(&self, duration: std::time::Duration) -> Sleep {
        Sleep::new(std::future::pending())
    }
}

fn set_never_ending_sleep_impl(builder: &mut Builder) {
    let sleep_impl = std::sync::Arc::new(ForeverSleep);
    builder.set_sleep_impl(Some(sleep_impl));
}

let mut builder = Config::builder();
set_never_ending_sleep_impl(&mut builder);
let config = builder.build();
Source

pub fn timeout_config(self, timeout_config: TimeoutConfig) -> Self

Set the timeout_config for the builder

§Examples
use stedi_sdk_client_guides::config::Config;
use stedi_sdk_client_guides::config::timeout::TimeoutConfig;

let timeout_config = TimeoutConfig::builder()
    .operation_attempt_timeout(Duration::from_secs(1))
    .build();
let config = Config::builder().timeout_config(timeout_config).build();
Source

pub fn set_timeout_config( &mut self, timeout_config: Option<TimeoutConfig>, ) -> &mut Self

Set the timeout_config for the builder

§Examples
use stedi_sdk_client_guides::config::{Builder, Config};
use stedi_sdk_client_guides::config::timeout::TimeoutConfig;

fn set_request_timeout(builder: &mut Builder) {
    let timeout_config = TimeoutConfig::builder()
        .operation_attempt_timeout(Duration::from_secs(1))
        .build();
    builder.set_timeout_config(Some(timeout_config));
}

let mut builder = Config::builder();
set_request_timeout(&mut builder);
let config = builder.build();
Source

pub fn app_name(self, app_name: AppName) -> Self

Sets the name of the app that is using the client.

This optional name is used to identify the application in the user agent that gets sent along with requests.

Source

pub fn set_app_name(&mut self, app_name: Option<AppName>) -> &mut Self

Sets the name of the app that is using the client.

This optional name is used to identify the application in the user agent that gets sent along with requests.

Source

pub fn endpoint_url(self, endpoint_url: impl Into<String>) -> Self

Sets the endpoint url used to communicate with this service Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix will be prefixed onto this URL. To fully override the endpoint resolver, use Builder::endpoint_resolver.

Source

pub fn set_endpoint_url(&mut self, endpoint_url: Option<String>) -> &mut Self

Sets the endpoint url used to communicate with this service Note: this is used in combination with other endpoint rules, e.g. an API that applies a host-label prefix will be prefixed onto this URL. To fully override the endpoint resolver, use Builder::endpoint_resolver.

Source

pub fn http_connector(self, http_connector: impl Into<HttpConnector>) -> Self

Sets the HTTP connector to use when making requests.

§Examples
use std::time::Duration;
use aws_smithy_client::{Client, hyper_ext};
use aws_smithy_client::erase::DynConnector;
use aws_smithy_client::http_connector::ConnectorSettings;
use stedi_sdk_client_guides::config::Config;

let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
    .with_webpki_roots()
    .https_only()
    .enable_http1()
    .enable_http2()
    .build();
let smithy_connector = hyper_ext::Adapter::builder()
    // Optionally set things like timeouts as well
    .connector_settings(
        ConnectorSettings::builder()
            .connect_timeout(Duration::from_secs(5))
            .build()
    )
    .build(https_connector);
Source

pub fn set_http_connector( &mut self, http_connector: Option<impl Into<HttpConnector>>, ) -> &mut Self

Sets the HTTP connector to use when making requests.

§Examples
use std::time::Duration;
use aws_smithy_client::hyper_ext;
use aws_smithy_client::http_connector::ConnectorSettings;
use crate::sdk_config::{SdkConfig, Builder};
use stedi_sdk_client_guides::config::{Builder, Config};

fn override_http_connector(builder: &mut Builder) {
    let https_connector = hyper_rustls::HttpsConnectorBuilder::new()
        .with_webpki_roots()
        .https_only()
        .enable_http1()
        .enable_http2()
        .build();
    let smithy_connector = hyper_ext::Adapter::builder()
        // Optionally set things like timeouts as well
        .connector_settings(
            ConnectorSettings::builder()
                .connect_timeout(Duration::from_secs(5))
                .build()
        )
        .build(https_connector);
    builder.set_http_connector(Some(smithy_connector));
}

let mut builder = stedi_sdk_client_guides::Config::builder();
override_http_connector(&mut builder);
let config = builder.build();
Source

pub fn region(self, region: impl Into<Option<Region>>) -> Self

Sets the AWS region to use when making requests.

§Examples
use aws_types::region::Region;
use stedi_sdk_client_guides::config::{Builder, Config};

let config = stedi_sdk_client_guides::Config::builder()
    .region(Region::new("us-east-1"))
    .build();
Source

pub fn set_test_defaults(&mut self) -> &mut Self

Apply test defaults to the builder

Source

pub fn with_test_defaults(self) -> Self

Apply test defaults to the builder

Source

pub fn build(self) -> Config

Builds a Config.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. Read more
Source§

impl From<&SdkConfig> for Builder

Source§

fn from(input: &SdkConfig) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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<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
Source§

impl<T> ErasedDestructor for T
where T: 'static,