pub struct ClientBuilder { /* private fields */ }Expand description
🏗️ 客户端构建器 - 流畅API
提供链式调用的客户端构建方式。配置状态委托给 core ConfigBuilder,
Client 仅叠加 30 秒默认超时与构建期严格校验策略。
§示例
use openlark_client::Client;
use openlark_client::Result;
use std::time::Duration;
fn main() -> Result<()> {
let _client = Client::builder()
.app_id("your_app_id")
.app_secret("your_app_secret")
.base_url("<https://open.feishu.cn>")
.timeout(Duration::from_secs(30))
.build()?;
Ok(())
}Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn app_secret<S: Into<String>>(self, app_secret: S) -> Self
pub fn app_secret<S: Into<String>>(self, app_secret: S) -> Self
🔑 设置应用密钥
Sourcepub fn enable_token_cache(self, enable: bool) -> Self
pub fn enable_token_cache(self, enable: bool) -> Self
🔐 设置是否允许自动获取 token(默认 true)
Sourcepub fn allow_custom_base_url(self, allow: bool) -> Self
pub fn allow_custom_base_url(self, allow: bool) -> Self
🔓 允许自定义 base_url 域名
Sourcepub fn retry_count(self, retry_count: u32) -> Self
pub fn retry_count(self, retry_count: u32) -> Self
🔄 设置重试次数
Sourcepub fn enable_log(self, enable: bool) -> Self
pub fn enable_log(self, enable: bool) -> Self
📝 启用或禁用日志
Sourcepub fn max_response_size(self, size: u64) -> Self
pub fn max_response_size(self, size: u64) -> Self
设置响应体最大大小限制(字节)
Sourcepub fn add_header<K, V>(self, key: K, value: V) -> Self
pub fn add_header<K, V>(self, key: K, value: V) -> Self
🔧 添加自定义 HTTP header
Trait Implementations§
Source§impl Clone for ClientBuilder
impl Clone for ClientBuilder
Source§fn clone(&self) -> ClientBuilder
fn clone(&self) -> ClientBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ClientBuilder
impl Debug for ClientBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for ClientBuilder
impl !UnwindSafe for ClientBuilder
impl Freeze for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
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