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.