Skip to main content

RuntimeCheckSpec

Enum RuntimeCheckSpec 

Source
pub enum RuntimeCheckSpec {
    CoordinatesInViewport,
    FiniteNumber,
    NumberInRange {
        min: i64,
        max: i64,
    },
    NonEmptyText,
    TextLength {
        min: usize,
        max: usize,
    },
}
Expand description

A named, parameterized check the host runs on produced values. 宿主对产出取值执行的具名参数化校验。

Variants§

§

CoordinatesInViewport

The rectangle fits inside its viewport and both spaces match. 矩形落在视口内,且两个坐标系一致。

§

FiniteNumber

The value is a finite number. 取值是有限数。

§

NumberInRange

The number lies within an inclusive range; inverted bounds fail. 数值落在闭区间内;边界倒置视为失败。

Fields

§min: i64

Inclusive lower bound. 闭区间下界。

§max: i64

Inclusive upper bound. 闭区间上界。

§

NonEmptyText

The text is not empty and not whitespace only. 文本非空且不全是空白。

§

TextLength

The text’s character count lies within an inclusive range. 文本的字符数落在闭区间内。

Fields

§min: usize

Inclusive minimum character count. 闭区间的最小字符数。

§max: usize

Inclusive maximum character count. 闭区间的最大字符数。

Implementations§

Source§

impl RuntimeCheckSpec

Source

pub const fn name(self) -> &'static str

Stable machine name written into failure evidence. 写入失败证据的稳定机器名。

Source

pub fn expression(self) -> String

Rust expression text that reconstructs this check in authored code. 在作者代码中重建该检查的 Rust 表达式文本。

Source

pub const fn number_in_range(min: i64, max: i64) -> RuntimeCheckSpec

Build an inclusive numeric range check. 构建闭区间数值校验。

Source

pub const fn text_length(min: usize, max: usize) -> RuntimeCheckSpec

Build an inclusive character-length check. 构建闭区间字符数校验。

Source

pub fn parse_list(value: &str) -> Result<Vec<RuntimeCheckSpec>, String>

Parse the compact names written by the authoring form. 解析创作表单写入的紧凑检查名称。

Source

pub fn run(self, value: &RuntimeValue) -> Result<(), RuntimeCheckFailure>

Evaluate the check against one value, reporting failure as evidence. 对单个取值执行检查,失败时以证据形式报告。

Trait Implementations§

Source§

impl Clone for RuntimeCheckSpec

Source§

fn clone(&self) -> RuntimeCheckSpec

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for RuntimeCheckSpec

Source§

impl Debug for RuntimeCheckSpec

Source§

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

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

impl Eq for RuntimeCheckSpec

Source§

impl PartialEq for RuntimeCheckSpec

Source§

fn eq(&self, other: &RuntimeCheckSpec) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RuntimeCheckSpec

Auto Trait Implementations§

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, 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.