Skip to main content

ConfigField

Struct ConfigField 

Source
pub struct ConfigField {
    pub key: String,
    pub label: String,
    pub kind: ConfigKind,
    pub default: String,
    pub help: Option<String>,
    pub needs_restart: bool,
}
Expand description

一个参数的自描述(BD-CFG 口径:key 与 Configurable::apply_config 受理的键一致)。

Fields§

§key: String

段内键名。

§label: String

界面标签(中文由插件自给)。

§kind: ConfigKind

型与界。

§default: String

缺省值(字符串形态,与段内形态一致)。

§help: Option<String>

一行说明(界面提示用;None = 无)。

§needs_restart: bool

改了要不要重启插件(BD-CFG-6 三档在元数据上的显形;false = 受理即生效)。

Implementations§

Source§

impl ConfigField

Source

pub fn new( key: impl Into<String>, label: impl Into<String>, kind: ConfigKind, ) -> Self

便捷构造(界/单位/说明走 ConfigKind 与后续 setter)。

Source

pub fn with_default(self, v: impl Into<String>) -> Self

链式补:缺省值。

Source

pub fn with_help(self, h: impl Into<String>) -> Self

链式补:一行说明。

Source

pub fn needs_restart(self, yes: bool) -> Self

链式补:标「重启插件才生效」(BD-CFG-6 的 deferred 口径在此显形)。

Source

pub fn validate(&self, raw: &str) -> Result<(), String>

校验一条原始输入(界面/CLI/导入共用)。Ok(()) = 可入段。

秘面字段:值不在本面(引用行由 ek-cfg 生成),恒 Ok —— 界面侧只显引用徽标。 (返回 Result 本身已 must_use,不叠 #[must_use]——clippy::double_must_use。)

Source

pub fn csv_ints(raw: &str) -> Result<Vec<i64>, String>

逗号整数表的解析器(去重保序,空项跳过)。dm 周期表等处复用同一条口径。 (返回 Result 本身已 must_use,不叠 #[must_use]。)

Trait Implementations§

Source§

impl Clone for ConfigField

Source§

fn clone(&self) -> Self

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 Debug for ConfigField

Source§

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

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

impl PartialEq for ConfigField

Source§

fn eq(&self, other: &Self) -> 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 ConfigField

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.