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 allow_custom_base_url(self, allow: bool) -> ClientBuilder
pub fn allow_custom_base_url(self, allow: bool) -> ClientBuilder
🔓 允许自定义 base_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 max_response_size(self, size: u64) -> ClientBuilder
pub fn max_response_size(self, size: u64) -> ClientBuilder
设置响应体最大大小限制(字节)
Sourcepub fn add_header<K, V>(self, key: K, value: V) -> ClientBuilder
pub fn add_header<K, V>(self, key: K, value: V) -> ClientBuilder
🔧 添加自定义 HTTP header
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 (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
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request