pub struct ClientConfig {
pub api_url: String,
pub mqtt_broker_url: String,
pub token: Option<String>,
pub user_id: Option<String>,
}Expand description
SDK 客户端配置
Fields§
§api_url: StringAPI 基础 URL(包含路径前缀)
mqtt_broker_url: StringMQTT Broker URL
token: Option<String>JWT Token 或 API Key(可选)
user_id: Option<String>用户 ID(可选,登录后设置)
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn from_env() -> Result<Self, SdkError>
pub fn from_env() -> Result<Self, SdkError>
从环境变量创建配置
§环境变量
AGENTLINK_API_KEY: API Key(必需)AGENTLINK_API_URL: API 基础 URL(可选,默认值:https://agentlink-api.feedecho.xyz)- 注意:只需要提供域名,不需要 /api/v1 路径
- MQTT URL 会自动从 API URL 推导出来
§Example
ⓘ
// 设置环境变量
std::env::set_var("AGENTLINK_API_KEY", "your-api-key");
std::env::set_var("AGENTLINK_API_URL", "https://agentlink-api.feedecho.xyz");
// 从环境变量创建配置
let config = ClientConfig::from_env().expect("Missing AGENTLINK_API_KEY");
// api_url = "https://agentlink-api.feedecho.xyz/api/v1"
// mqtt_url = "mqtts://mqtt.feedecho.xyz:8883"Sourcepub fn try_from_env() -> Option<Self>
pub fn try_from_env() -> Option<Self>
Sourcepub fn with_token(self, token: String) -> Self
pub fn with_token(self, token: String) -> Self
设置 Token
Sourcepub fn with_user_id(self, user_id: String) -> Self
pub fn with_user_id(self, user_id: String) -> Self
设置用户 ID
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 UnsafeUnpin 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