Skip to main content

Args

Struct Args 

Source
pub struct Args {
    pub content: String,
    pub version: u32,
    pub scene: Scene,
    pub openid: String,
    pub title: Option<String>,
    pub nickname: Option<String>,
    pub signature: Option<String>,
}
Expand description

微信内容安全检测请求参数

用于配置内容安全检测的各项参数,包括检测内容、场景、用户信息等。

§字段说明

  • content: 待检测的文本内容,最大长度2500字符
  • version: 接口版本号,固定为2
  • scene: 检测场景,不同场景有不同的检测策略
  • openid: 用户openid,用户需在近两小时访问过小程序
  • title: 文本标题(可选)
  • nickname: 用户昵称(可选)
  • signature: 个性签名,仅在资料场景有效(可选)

§示例

use wechat_minapp::minapp_security::{Args, Scene};

let args = Args::new("待检测的文本内容", Scene::Comment, "user_openid");
assert_eq!(args.content_length(), 18);
assert!(args.is_profile_scene());

Fields§

§content: String

需检测的文本内容,文本字数的上限为2500字,需使用UTF-8编码

§version: u32

接口版本号,2.0版本为固定值2

§scene: Scene

场景枚举值

§openid: String

用户的openid(用户需在近两小时访问过小程序)

§title: Option<String>

文本标题,需使用UTF-8编码

§nickname: Option<String>

用户昵称,需使用UTF-8编码

§signature: Option<String>

个性签名,该参数仅在资料类场景有效(scene=1),需使用UTF-8编码

Implementations§

Source§

impl Args

Source

pub fn builder() -> ArgsBuilder

创建构建器

Source

pub fn new( content: impl Into<String>, scene: Scene, openid: impl Into<String>, ) -> Self

快速创建基本参数(使用默认版本2)

Source

pub fn is_profile_scene(&self) -> bool

检查是否为资料场景

Source

pub fn content_length(&self) -> usize

获取内容长度

Source

pub fn validate(&self) -> Result<()>

验证参数是否有效

Trait Implementations§

Source§

impl Clone for Args

Source§

fn clone(&self) -> Args

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Args

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for Args

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Args

§

impl RefUnwindSafe for Args

§

impl Send for Args

§

impl Sync for Args

§

impl Unpin for Args

§

impl UnsafeUnpin for Args

§

impl UnwindSafe for Args

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,