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
impl ClientConfig
Sourcepub fn builder() -> ClientConfigBuilder<((), (), (), (), (), ())>
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
impl ClientConfig
Sourcepub fn with_region(region: Region) -> Self
pub fn with_region(region: Region) -> Self
使用指定地域创建配置
§示例
use tencentcloud_sms::{ClientConfig, Region};
let config = ClientConfig::with_region(Region::ApBeijing);Sourcepub fn financial_shanghai() -> Self
pub fn financial_shanghai() -> Self
使用上海金融地域创建配置
自动设置 Region 为上海金融区,Endpoint 为 Region 接入点。
§示例
use tencentcloud_sms::ClientConfig;
let config = ClientConfig::financial_shanghai();Sourcepub fn financial_shenzhen() -> Self
pub fn financial_shenzhen() -> Self
使用深圳金融地域创建配置
自动设置 Region 为深圳金融区,Endpoint 为 Region 接入点。
§示例
use tencentcloud_sms::ClientConfig;
let config = ClientConfig::financial_shenzhen();Sourcepub fn international() -> Self
pub fn international() -> Self
Sourcepub fn with_timeout(timeout: Duration) -> Self
pub fn with_timeout(timeout: Duration) -> Self
自定义超时时间
§示例
use std::time::Duration;
use tencentcloud_sms::ClientConfig;
let config = ClientConfig::with_timeout(Duration::from_secs(60));Sourcepub fn without_retry() -> Self
pub fn without_retry() -> Self
Sourcepub fn with_retry(retry: RetryConfig) -> Self
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);Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ClientConfig
impl Debug for ClientConfig
Auto Trait Implementations§
impl Freeze for ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnwindSafe for ClientConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more