wx_rust_common/bean/wx_jsapi_signature.rs
1//! jsapi 签名数据对象。
2//!
3//! 对应 Java `me.chanjar.weixin.common.bean.WxJsapiSignature`。
4
5/// jsapi 签名结果。
6///
7/// 用于 JS-SDK 的前端配置签名(`wx.config`)。
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct WxJsapiSignature {
10 /// 公众号 appId
11 pub app_id: String,
12
13 /// 随机串
14 pub nonce_str: String,
15
16 /// 时间戳(秒)
17 pub timestamp: i64,
18
19 /// 需要签名的 URL
20 pub url: String,
21
22 /// 签名值
23 pub signature: String,
24}
25
26impl WxJsapiSignature {
27 /// 构建 jsapi 签名结果。
28 ///
29 /// # 参数
30 /// - `app_id`:公众号 appId
31 /// - `nonce_str`:随机串
32 /// - `timestamp`:时间戳(秒)
33 /// - `url`:需要签名的 URL
34 /// - `signature`:签名值
35 pub fn new(
36 app_id: impl Into<String>,
37 nonce_str: impl Into<String>,
38 timestamp: i64,
39 url: impl Into<String>,
40 signature: impl Into<String>,
41 ) -> Self {
42 Self {
43 app_id: app_id.into(),
44 nonce_str: nonce_str.into(),
45 timestamp,
46 url: url.into(),
47 signature: signature.into(),
48 }
49 }
50}