Skip to main content

SelectField

Struct SelectField 

Source
#[non_exhaustive]
pub struct SelectField { pub name: String, pub label: String, pub multiple: bool, pub options: Vec<String>, pub placeholder: String, pub prerequisites: Vec<String>, pub required: bool, pub supports_suggestions: bool, }
Expand description

Defines a field that allows selection from a predefined list of options.

Values to be selected from can be either hard-coded in the schema, or (only for query forms) fetched on-demand the same way as auto-suggestions.

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.
§name: String

Name of the field as it will be included in the encoded query or config object.

§label: String

Suggested label to display along the field.

§multiple: bool

Whether multiple values may be selected.

§options: Vec<String>

A list of options to select from.

In addition to the options in this list, the auto-suggest mechanism can also fetch options when the user starts typing in this field. In this case, supports_suggestions should be set to true.

§placeholder: String

Suggested placeholder to display when there is no value.

§prerequisites: Vec<String>

An optional list of fields that should be filled in before allowing the user to fill in this field. This forces a certain ordering in the data entry, which enables richer auto-suggestions, since the filled in prerequisite fields can provide additional context.

§required: bool

Whether a value is required.

§supports_suggestions: bool

Whether the provider supports auto-suggestions for this field.

Implementations§

Source§

impl SelectField

Source

pub fn new() -> Self

Creates a new select field with all default values.

Source

pub fn multiple(self) -> Self

Marks the field as allowing multiple values.

Source

pub fn required(self) -> Self

Marks the field as required.

Source

pub fn with_label(self, label: impl Into<String>) -> Self

Source

pub fn with_name(self, name: impl Into<String>) -> Self

Source

pub fn with_options(self, options: impl Into<Vec<String>>) -> Self

Source

pub fn with_placeholder(self, placeholder: impl Into<String>) -> Self

Source

pub fn with_prerequisites(self, prerequisites: impl Into<Vec<String>>) -> Self

Source

pub fn with_suggestions(self) -> Self

Marks the field as supporting auto-suggestions.

Trait Implementations§

Source§

impl Clone for SelectField

Source§

fn clone(&self) -> SelectField

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 SelectField

Source§

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

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

impl Default for SelectField

Source§

fn default() -> SelectField

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SelectField

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<SelectField> for ConfigField

Source§

fn from(field: SelectField) -> Self

Converts to this type from the input type.
Source§

impl From<SelectField> for QueryField

Source§

fn from(field: SelectField) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for SelectField

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for SelectField

Source§

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

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

impl StructuralPartialEq for SelectField

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> BindgenSerializable for T

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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