Skip to main content

Descriptor

Struct Descriptor 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: f64

Shown value = value × scale.

§precision: u32

Decimals 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: Writers

Who may write it besides its owner.

§sensitive: bool

A 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.

Experimental: may change in any release (docs/stability.md).
§note: bool

Not 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

Source

pub fn note(text: &str) -> Descriptor

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.

Source

pub fn float(label: &str, min: f64, max: f64, default: f64) -> Descriptor

A float in [min, max], its fine step a hundredth of the range.

Source

pub fn int(label: &str, min: i64, max: i64, default: i64) -> Descriptor

Source

pub fn bool(label: &str, default: bool) -> Descriptor

Source

pub fn choice(label: &str, choices: &[&str], default: &str) -> Descriptor

Source

pub fn text(label: &str, default: &str) -> Descriptor

Source

pub fn floats( label: &str, count: u32, min: f64, max: f64, default: &[f64], ) -> Descriptor

Floats in [min, max], at most count of them.

Source

pub fn ints( label: &str, count: u32, min: i64, max: i64, default: &[i64], ) -> Descriptor

Ints in [min, max], at most count of them.

Source

pub fn path(label: &str, kind: PathKind, extensions: &[&str]) -> Descriptor

A text naming a directory or a file, empty by default; for a file, the extensions accepted (none: any).

Source

pub fn dialog_title(self, title: &str) -> Descriptor

A path’s chooser title, a task (“Open a workspace”) rather than the field’s label; nothing for a value that names no path.

Source

pub fn dialog_purpose(self, key: &str) -> Descriptor

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.

Source

pub fn filter_name(self, name: &str) -> Descriptor

What a path’s chooser calls its extensions’ filter (“Enrolment files”); nothing for a value that names no path.

Source

pub fn description(self, text: &str) -> Descriptor

Source

pub fn soft(self, lo: f64, hi: f64) -> Descriptor

The range a slider spans, within the hard range.

Source

pub fn step(self, step: f64) -> Descriptor

The fine step (the coarse one becomes ten of them).

Source

pub fn coarse(self, coarse: f64) -> Descriptor

Source

pub fn unit(self, unit: &str) -> Descriptor

Source

pub fn display(self, scale: f64, precision: u32) -> Descriptor

Shown value = value × scale, with so many decimals.

Source

pub fn capacity(self, bytes: u32) -> Descriptor

At most so many bytes of text.

Source

pub fn writers(self, writers: &[OwnerId]) -> Descriptor

Lets these write it too, besides its owner (one writer per value otherwise).

Source

pub fn any_writer(self) -> Descriptor

Lets anyone write it.

Source

pub fn scopes(self, scopes: &[ValueScope]) -> Descriptor

Opts into host value scopes: the settings app offers “Set for” with app and these (those the host has open).

Experimental: may change in any release (docs/stability.md).
Source

pub fn sensitive(self) -> Descriptor

A secret: left out of settings exports and refused from them.

Source

pub fn accept(&self, json: &Value) -> Result<Value, String>

Checks a value read from outside (an imported file) against what the value can be: its type, its hard range (refused, never clamped), its choices, its count and its capacity. The value as the store holds it, or why not.

Trait Implementations§

Source§

impl Clone for Descriptor

Source§

fn clone(&self) -> Descriptor

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Descriptor

Source§

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

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

impl PartialEq for Descriptor

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Descriptor

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Descriptor

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

§

impl<T> TryClone for T
where T: Clone,

§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,