pub struct ClientBuilder { /* private fields */ }Expand description
🏗️ 客户端构建器 - 流畅API
提供链式调用的客户端构建方式
§示例
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 new() -> ClientBuilder
pub fn new() -> ClientBuilder
🆕 创建新的构建器实例
Sourcepub fn app_id<S>(self, app_id: S) -> ClientBuilder
pub fn app_id<S>(self, app_id: S) -> ClientBuilder
🆔 设置应用ID
Sourcepub fn app_secret<S>(self, app_secret: S) -> ClientBuilder
pub fn app_secret<S>(self, app_secret: S) -> ClientBuilder
🔑 设置应用密钥
Sourcepub fn app_type(self, app_type: AppType) -> ClientBuilder
pub fn app_type(self, app_type: AppType) -> ClientBuilder
🏷️ 设置应用类型(自建 / 商店)
Sourcepub fn enable_token_cache(self, enable: bool) -> ClientBuilder
pub fn enable_token_cache(self, enable: bool) -> ClientBuilder
🔐 设置是否允许自动获取 token(默认 true)
Sourcepub fn base_url<S>(self, base_url: S) -> ClientBuilder
pub fn base_url<S>(self, base_url: S) -> ClientBuilder
🌐 设置基础URL
Sourcepub fn timeout(self, timeout: Duration) -> ClientBuilder
pub fn timeout(self, timeout: Duration) -> ClientBuilder
⏱️ 设置请求超时时间
Sourcepub fn retry_count(self, retry_count: u32) -> ClientBuilder
pub fn retry_count(self, retry_count: u32) -> ClientBuilder
🔄 设置重试次数
Sourcepub fn enable_log(self, enable: bool) -> ClientBuilder
pub fn enable_log(self, enable: bool) -> ClientBuilder
📝 启用或禁用日志
Sourcepub fn from_env(self) -> ClientBuilder
pub fn from_env(self) -> ClientBuilder
🌍 从环境变量加载配置
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 · 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
Source§impl Default for ClientBuilder
impl Default for ClientBuilder
Source§fn default() -> ClientBuilder
fn default() -> ClientBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
impl !UnwindSafe 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