#[non_exhaustive]pub struct Descriptor {Show 19 fields
pub ty: Type,
pub label: String,
pub description: String,
pub default: Value,
pub hard: Option<(f64, f64)>,
pub soft: Option<(f64, f64)>,
pub step: f64,
pub coarse: f64,
pub unit: Option<String>,
pub display_scale: f64,
pub precision: u32,
pub choices: Vec<String>,
pub count: Option<u32>,
pub capacity: Option<u32>,
pub path: Option<PathHint>,
pub writers: Writers,
pub sensitive: bool,
pub scopes: Vec<ValueScope>,
pub note: bool,
}Expand description
What a value is and how it is shown and moved.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.ty: Type§label: String§description: String§default: Value§hard: Option<(f64, f64)>What the value can be, at most.
soft: Option<(f64, f64)>What a slider spans; past it up to hard only when forced.
step: f64§coarse: f64§unit: Option<String>§display_scale: f64Shown value = value × scale.
precision: u32Decimals shown.
choices: Vec<String>§count: Option<u32>How many values a list holds at most.
capacity: Option<u32>How many bytes a text holds at most.
path: Option<PathHint>A text that names a path on disk.
writers: WritersWho may write it besides its owner.
sensitive: boolA secret (a token, a password): never written to a settings export, never read from one.
scopes: Vec<ValueScope>The host’s value scopes it may also be set for, above app
(opt-in, crate::admin::ValueScope); empty: app-wide only.
note: boolNot a value but a read-only line, its words the label
(Descriptor::note): a dialog’s form shows it under the fields
before it and answers no value for it.
Implementations§
Source§impl Descriptor
impl Descriptor
Sourcepub fn note(text: &str) -> Self
pub fn note(text: &str) -> Self
A read-only line of a form, what the command will also do (“Also
updates 2 templates”): the forms’ counterpart of the admin forms’
note field kind.
Sourcepub fn float(label: &str, min: f64, max: f64, default: f64) -> Self
pub fn float(label: &str, min: f64, max: f64, default: f64) -> Self
A float in [min, max], its fine step a hundredth of the range.
pub fn int(label: &str, min: i64, max: i64, default: i64) -> Self
pub fn bool(label: &str, default: bool) -> Self
pub fn choice(label: &str, choices: &[&str], default: &str) -> Self
pub fn text(label: &str, default: &str) -> Self
Sourcepub fn floats(
label: &str,
count: u32,
min: f64,
max: f64,
default: &[f64],
) -> Self
pub fn floats( label: &str, count: u32, min: f64, max: f64, default: &[f64], ) -> Self
Floats in [min, max], at most count of them.
Sourcepub fn ints(
label: &str,
count: u32,
min: i64,
max: i64,
default: &[i64],
) -> Self
pub fn ints( label: &str, count: u32, min: i64, max: i64, default: &[i64], ) -> Self
Ints in [min, max], at most count of them.
Sourcepub fn path(label: &str, kind: PathKind, extensions: &[&str]) -> Self
pub fn path(label: &str, kind: PathKind, extensions: &[&str]) -> Self
A text naming a directory or a file, empty by default; for a file, the extensions accepted (none: any).
Sourcepub fn dialog_title(self, title: &str) -> Self
pub fn dialog_title(self, title: &str) -> Self
A path’s chooser title, a task (“Open a workspace”) rather than the field’s label; nothing for a value that names no path.
Sourcepub fn dialog_purpose(self, key: &str) -> Self
pub fn dialog_purpose(self, key: &str) -> Self
The key a path’s chooser remembers its last folder under (default: the form’s command and the field’s key); nothing for a value that names no path.
Sourcepub fn filter_name(self, name: &str) -> Self
pub fn filter_name(self, name: &str) -> Self
What a path’s chooser calls its extensions’ filter (“Enrolment files”); nothing for a value that names no path.
pub fn description(self, text: &str) -> Self
pub fn coarse(self, coarse: f64) -> Self
pub fn unit(self, unit: &str) -> Self
Sourcepub fn display(self, scale: f64, precision: u32) -> Self
pub fn display(self, scale: f64, precision: u32) -> Self
Shown value = value × scale, with so many decimals.
Sourcepub fn writers(self, writers: &[OwnerId]) -> Self
pub fn writers(self, writers: &[OwnerId]) -> Self
Lets these write it too, besides its owner (one writer per value otherwise).
Sourcepub fn any_writer(self) -> Self
pub fn any_writer(self) -> Self
Lets anyone write it.
Sourcepub fn scopes(self, scopes: &[ValueScope]) -> Self
pub fn scopes(self, scopes: &[ValueScope]) -> Self
Opts into host value scopes: the settings app offers “Set for”
with app and these (those the host has open).
Trait Implementations§
Source§impl Clone for Descriptor
impl Clone for Descriptor
Source§fn clone(&self) -> Descriptor
fn clone(&self) -> Descriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more