pub struct ConfigFieldSchema {
pub name: String,
pub field_type: ConfigFieldType,
pub required: bool,
pub min: Option<f64>,
pub max: Option<f64>,
pub min_length: Option<usize>,
pub max_length: Option<usize>,
pub allowed_values: Option<Vec<String>>,
}Expand description
配置字段 schema 定义
Fields§
§name: String字段名
field_type: ConfigFieldType字段类型
required: bool是否必填
min: Option<f64>最小值(数值类型)
max: Option<f64>最大值(数值类型)
min_length: Option<usize>最小长度(字符串类型)
max_length: Option<usize>最大长度(字符串类型)
allowed_values: Option<Vec<String>>枚举允许值
Implementations§
Source§impl ConfigFieldSchema
impl ConfigFieldSchema
pub fn new(name: impl Into<String>, field_type: ConfigFieldType) -> Self
pub fn required(self) -> Self
pub fn with_range(self, min: f64, max: f64) -> Self
pub fn with_length(self, min: usize, max: usize) -> Self
pub fn with_allowed_values(self, values: Vec<String>) -> Self
Trait Implementations§
Source§impl Clone for ConfigFieldSchema
impl Clone for ConfigFieldSchema
Source§fn clone(&self) -> ConfigFieldSchema
fn clone(&self) -> ConfigFieldSchema
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigFieldSchema
impl Debug for ConfigFieldSchema
Source§impl<'de> Deserialize<'de> for ConfigFieldSchema
impl<'de> Deserialize<'de> for ConfigFieldSchema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ConfigFieldSchema
impl RefUnwindSafe for ConfigFieldSchema
impl Send for ConfigFieldSchema
impl Sync for ConfigFieldSchema
impl Unpin for ConfigFieldSchema
impl UnsafeUnpin for ConfigFieldSchema
impl UnwindSafe for ConfigFieldSchema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more