Enum amplify_syn::ListReq

source ·
pub enum ListReq<T> {
    Single {
        whitelist: Option<Vec<T>>,
        default: Option<T>,
    },
    Many {
        whitelist: Option<Vec<T>>,
        required: bool,
        max_no: Option<u8>,
    },
    Predefined {
        whitelist: Option<Vec<T>>,
        default: Vec<T>,
    },
    Deny,
}
Expand description

Requirements for list elements. For instance, used in AttrReq for providing crate::ParametrizedAttr fields requirements.

Variants§

§

Single

Fields

§whitelist: Option<Vec<T>>

Restricts set of possible values to the given whitelist

NB: If whitelist does not contain values from the default field, they are still accepted as valid, i.e. “automatically whitelisted”

§default: Option<T>

Default value assigned as a signe list item if no values are provided

NB: If whitelist does not contain values from the default field, they are still accepted as valid, i.e. “automatically whitelisted”

Only a single value allowed and it must be present

§

Many

Fields

§whitelist: Option<Vec<T>>

Restricts set of possible values to the given whitelist

§required: bool

Require that at least one value is present

§max_no: Option<u8>

Restricts the maximum number of items

Any number of any elements may be present

§

Predefined

Fields

§whitelist: Option<Vec<T>>

Restricts set of possible values to the given whitelist.

NB: If whitelist does not contain values from the default field, they are still accepted as valid, i.e. “automatically whitelisted”

§default: Vec<T>

Default set of values for the list used if no values are provided

NB: If whitelist does not contain values from the default field, they are still accepted as valid, i.e. “automatically whitelisted”

Any number of any elements may not be present; if none of the elements is present the list will use default vec of the values

§

Deny

Element must not be present

Implementations§

source§

impl<T> ListReq<T>

source

pub fn maybe_one(name: T) -> Self

Convenience constructor for list requiring presence of an optional single element.

source

pub fn one_of(names: Vec<T>) -> Self

Convenience constructor for list requiring presence of a single element from a list of possible values.

source

pub fn any_of(names: Vec<T>, required: bool) -> Self

Convenience constructor for list requiring presence of multiple elements from a list of possible values.

source§

impl<T> ListReq<T>where T: Clone + ToTokens,

source

pub fn check( &self, value: &mut Vec<T>, attr: impl ToString, arg: impl ToString ) -> Result<(), Error>

Checks the value against the list requirements, generating Error if the requirements are not met.

Trait Implementations§

source§

impl<T: Clone> Clone for ListReq<T>

source§

fn clone(&self) -> ListReq<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for ListReq<T>where T: RefUnwindSafe,

§

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

§

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

§

impl<T> Unpin for ListReq<T>where T: Unpin,

§

impl<T> UnwindSafe for ListReq<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.