pub struct Client {
pub auth: AuthClient,
pub communication: CommunicationClient,
/* private fields */
}Expand description
🚀 OpenLark客户端 - 极简设计
§特性
- 零配置启动:
Client::from_env() - 单入口:meta 链式字段访问(
client.docs/...) - 编译时feature优化
- 高性能异步
- 现代化错误处理
§示例
use openlark_client::prelude::*;
#[tokio::main]
async fn main() -> Result<()> {
// 从环境变量创建客户端
let client = Client::from_env()?;
// meta 链式入口(需要对应 feature)
// - 通讯:client.communication.im...
// - 文档:client.docs.config()...
// - 认证:client.auth.app / client.auth.user / client.auth.oauth
Ok(())
}Fields§
§auth: AuthClientAuth meta 调用链入口:client.auth.app / client.auth.user / client.auth.oauth
communication: CommunicationClientCommunication meta 调用链入口:client.communication.im / client.communication.contact …
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
🏗️ 创建构建器
Sourcepub fn core_config(&self) -> &Config
pub fn core_config(&self) -> &Config
🔧 获取底层 core 配置
与 Self::config 返回同一份配置。保留此别名是为了向后兼容。
Sourcepub fn api_config(&self) -> &Config
pub fn api_config(&self) -> &Config
🔧 获取可直接传给函数式 API 的认证后配置
与 Self::config 返回同一份配置。保留此别名是为了让
业务侧更容易理解它的用途:可直接传给 openlark_docs::*、
openlark_auth::* 等函数式 API。
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
✅ 检查客户端是否已正确配置
Sourcepub fn with_core_config(config: Config) -> Result<Self>
pub fn with_core_config(config: Config) -> Result<Self>
🆕 使用统一 CoreConfig 创建客户端
与 ClientBuilder::build 共用私有构造 seam:Config::validate(含域名白名单)
- Client 零超时规则 + token provider 装配。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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