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. 数值落在闭区间内;边界倒置视为失败。
NonEmptyText
The text is not empty and not whitespace only. 文本非空且不全是空白。
TextLength
The text’s character count lies within an inclusive range. 文本的字符数落在闭区间内。
Implementations§
Source§impl RuntimeCheckSpec
impl RuntimeCheckSpec
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
Stable machine name written into failure evidence. 写入失败证据的稳定机器名。
Sourcepub fn expression(self) -> String
pub fn expression(self) -> String
Rust expression text that reconstructs this check in authored code. 在作者代码中重建该检查的 Rust 表达式文本。
Sourcepub const fn number_in_range(min: i64, max: i64) -> RuntimeCheckSpec
pub const fn number_in_range(min: i64, max: i64) -> RuntimeCheckSpec
Build an inclusive numeric range check. 构建闭区间数值校验。
Sourcepub const fn text_length(min: usize, max: usize) -> RuntimeCheckSpec
pub const fn text_length(min: usize, max: usize) -> RuntimeCheckSpec
Build an inclusive character-length check. 构建闭区间字符数校验。
Sourcepub fn parse_list(value: &str) -> Result<Vec<RuntimeCheckSpec>, String>
pub fn parse_list(value: &str) -> Result<Vec<RuntimeCheckSpec>, String>
Parse the compact names written by the authoring form. 解析创作表单写入的紧凑检查名称。
Sourcepub fn run(self, value: &RuntimeValue) -> Result<(), RuntimeCheckFailure>
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
impl Clone for RuntimeCheckSpec
Source§fn clone(&self) -> RuntimeCheckSpec
fn clone(&self) -> RuntimeCheckSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more