Skip to main content

dingtalk_stream/
credential.rs

1//! 凭证管理
2
3/// 钉钉应用凭证
4#[derive(Clone)]
5pub struct Credential {
6    /// 应用的 client_id (appKey)
7    pub client_id: String,
8    /// 应用的 client_secret (appSecret)
9    pub client_secret: String,
10}
11
12impl Credential {
13    /// 创建新的凭证
14    pub fn new(client_id: impl Into<String>, client_secret: impl Into<String>) -> Self {
15        Self {
16            client_id: client_id.into(),
17            client_secret: client_secret.into(),
18        }
19    }
20}
21
22impl std::fmt::Debug for Credential {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        f.debug_struct("Credential")
25            .field("client_id", &self.client_id)
26            .field("client_secret", &"***")
27            .finish()
28    }
29}
30
31impl std::fmt::Display for Credential {
32    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33        write!(f, "Credential(client_id={})", self.client_id)
34    }
35}