pub enum ParamType {
Any,
Bool,
Number,
String,
Array(Box<ParamType>),
Object(Box<ParamType>),
OneOf(Vec<ParamType>),
Nullable(Box<ParamType>),
}Expand description
A type hint for a function parameter.
The parameter type is used to validate the arguments of a function call expression before evaluating the function.
See the documentation of FuncDef for usage examples.
Variants§
Any
Any type is allowed.
Bool
The parameter must be a boolean value.
Number
The parameter must be a number.
String
The parameter must be a string value.
Array(Box<ParamType>)
The parameter must be an array which must contain only elements of the given element type.
Object(Box<ParamType>)
The parameter must be an object which must contain only entries with values of the given element type. The object key type is always a string.
OneOf(Vec<ParamType>)
The parameter can be one of the provided types. If the Vec is empty, any type is
allowed.
Nullable(Box<ParamType>)
The parameter must be either null or of the provided type.
Implementations§
source§impl ParamType
impl ParamType
sourcepub fn array_of(element: ParamType) -> Self
pub fn array_of(element: ParamType) -> Self
Creates a new Array parameter type with the given element type.
sourcepub fn object_of(element: ParamType) -> Self
pub fn object_of(element: ParamType) -> Self
Creates a new Object parameter type with the given element type.
The object key type is always a string and thus not specified here.
sourcepub fn one_of<I>(alternatives: I) -> Selfwhere
I: IntoIterator<Item = ParamType>,
pub fn one_of<I>(alternatives: I) -> Selfwhere
I: IntoIterator<Item = ParamType>,
Creates a new OneOf parameter type from the provided alternatives.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ParamType
impl RefUnwindSafe for ParamType
impl Send for ParamType
impl Sync for ParamType
impl Unpin for ParamType
impl UnwindSafe for ParamType
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)