ClientConfig

Struct ClientConfig 

Source
pub struct ClientConfig {
    pub region: Region,
    pub endpoint: Endpoint,
    pub timeout: Duration,
    pub retry: Option<RetryConfig>,
    pub proxy: Option<String>,
    pub is_https: bool,
}
Expand description

客户端配置

§示例

use tencentcloud_sms::{ClientConfig, Region, Endpoint};

// 默认配置(广州地域,就近接入)
let config = ClientConfig::default();

// 指定地域
let config = ClientConfig::builder()
    .region(Region::ApBeijing)
    .build();

// 金融地域(需使用 Region 接入点)
let config = ClientConfig::builder()
    .region(Region::ApShanghaiFsi)
    .endpoint(Endpoint::Region)
    .build();

// 国际短信
let config = ClientConfig::builder()
    .endpoint(Endpoint::International)
    .build();

Fields§

§region: Region

服务地域

指定 API 的服务地域,用于 X-TC-Region 请求头。 默认为广州 (ApGuangzhou)。

§endpoint: Endpoint

接入点配置

  • Nearest: 就近接入(默认)
  • Region(region): 指定地域接入点
  • International: 国际短信接入点
  • Custom(host): 自定义域名
§timeout: Duration

请求超时时间

§retry: Option<RetryConfig>

重试配置

§proxy: Option<String>

代理服务器地址

§is_https: bool

是否使用 HTTPS

Implementations§

Source§

impl ClientConfig

Source

pub fn builder() -> ClientConfigBuilder<((), (), (), (), (), ())>

Create a builder for building ClientConfig. On the builder, call .region(...)(optional), .endpoint(...)(optional), .timeout(...)(optional), .retry(...)(optional), .proxy(...)(optional), .is_https(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of ClientConfig.

Source§

impl ClientConfig

Source

pub fn new() -> Self

创建默认配置

Source

pub fn validate(&self) -> SmsResult<()>

验证配置是否合法

§错误
  • 超时时间为 0
  • 金融地域未使用 Region 接入点
  • 重试配置参数无效
Source

pub fn with_region(region: Region) -> Self

使用指定地域创建配置

§示例
use tencentcloud_sms::{ClientConfig, Region};

let config = ClientConfig::with_region(Region::ApBeijing);
Source

pub fn financial_shanghai() -> Self

使用上海金融地域创建配置

自动设置 Region 为上海金融区,Endpoint 为 Region 接入点。

§示例
use tencentcloud_sms::ClientConfig;

let config = ClientConfig::financial_shanghai();
Source

pub fn financial_shenzhen() -> Self

使用深圳金融地域创建配置

自动设置 Region 为深圳金融区,Endpoint 为 Region 接入点。

§示例
use tencentcloud_sms::ClientConfig;

let config = ClientConfig::financial_shenzhen();
Source

pub fn international() -> Self

使用国际短信接入点创建配置

§示例
use tencentcloud_sms::ClientConfig;

let config = ClientConfig::international();
Source

pub fn with_timeout(timeout: Duration) -> Self

自定义超时时间

§示例
use std::time::Duration;
use tencentcloud_sms::ClientConfig;

let config = ClientConfig::with_timeout(Duration::from_secs(60));
Source

pub fn without_retry() -> Self

禁用重试

§示例
use tencentcloud_sms::ClientConfig;

let config = ClientConfig::without_retry();
Source

pub fn with_retry(retry: RetryConfig) -> Self

自定义重试配置

§示例
use tencentcloud_sms::{ClientConfig, RetryConfig};

let retry_config = RetryConfig::builder()
    .max_retries(5)
    .build();
let config = ClientConfig::with_retry(retry_config);
Source

pub fn host(&self) -> &str

获取实际使用的域名

Trait Implementations§

Source§

impl Clone for ClientConfig

Source§

fn clone(&self) -> ClientConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClientConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ClientConfig

Source§

fn default() -> Self

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where 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