Skip to main content

wechat_mp_security/
lib.rs

1//! 小程序内容安全与安全风控
2
3mod content;
4mod risk;
5
6pub use content::{
7    media_check_async, msg_sec_check, MediaCheckAsyncRequest, MediaCheckAsyncResponse,
8    MsgSecCheckRequest, MsgSecCheckResponse, MsgSecCheckResult,
9};
10pub use risk::{get_user_risk_rank, GetUserRiskRankRequest, GetUserRiskRankResponse};
11
12use wechat_mp_core::MpClient;
13
14/// 安全相关 API 门面
15#[derive(Clone)]
16pub struct SecurityApi {
17    client: MpClient,
18}
19
20impl SecurityApi {
21    /// 基于客户端创建
22    pub fn new(client: MpClient) -> Self {
23        Self { client }
24    }
25
26    /// 文本内容安全识别
27    pub async fn msg_sec_check(
28        &self,
29        req: &MsgSecCheckRequest,
30    ) -> wechat_mp_core::Result<MsgSecCheckResponse> {
31        msg_sec_check(&self.client, req).await
32    }
33
34    /// 多媒体内容安全识别(异步)
35    pub async fn media_check_async(
36        &self,
37        req: &MediaCheckAsyncRequest,
38    ) -> wechat_mp_core::Result<MediaCheckAsyncResponse> {
39        media_check_async(&self.client, req).await
40    }
41
42    /// 获取用户安全等级
43    pub async fn get_user_risk_rank(
44        &self,
45        req: &GetUserRiskRankRequest,
46    ) -> wechat_mp_core::Result<GetUserRiskRankResponse> {
47        get_user_risk_rank(&self.client, req).await
48    }
49}