Macro mz_sql::normalize::generate_extracted_config
source · macro_rules! generate_extracted_config { ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty), $($tail:tt),*) => { ... }; ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty)) => { ... }; ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, Default($v:expr)), $($tail:tt),*) => { ... }; ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, Default($v:expr))) => { ... }; ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, AllowMultiple), $($tail:tt),*) => { ... }; ($option_ty:ty, [$($processed:tt)*], ($option_name:path, $t:ty, AllowMultiple)) => { ... }; ($option_ty:ty, [$(($option_name:path, $t:ty, $v:expr, $allow_multiple:literal))+]) => { ... }; ($option_ty:ty, $($h:tt),+) => { ... }; (@ifexpr false, $lhs:expr, $rhs:expr) => { ... }; (@ifexpr true, $lhs:expr, $rhs:expr) => { ... }; (@ifty false, $lhs:ty, $rhs:ty) => { ... }; (@ifty true, $lhs:ty, $rhs:ty) => { ... }; }
Expand description
Generates a struct capable of taking a Vec
of types commonly used to
represent WITH
options into useful data types, such as strings.
Additionally, it is able to convert the useful data types back to the Vec
of options.
§Parameters
$option_ty
: Accepts a struct representing a set ofWITH
options, which must contain the fieldsname
andvalue
.name
must be of type$option_tyName
, e.g. if$option_ty
isFooOption
, thenname
must be of typeFooOptionName
.$option_tyName
must be an enum representingWITH
option keys.TryFromValue<value>
must be implemented for the type you want to take the option to. Thesql::plan::with_option
module contains these implementations.
$option_name
must be an element of$option_tyName
$t
is the type you want to convert the option’s value to. If the option’s value is absent (i.e. the user only entered the option’s key), you can also define a default value.Default($v)
is an optional parameter that sets the default value of the field to$v
.$v
must be convertible to$t
using.into
. This also converts the struct’s type fromOption<$t>
to<$t>
.AllowMultiple
is an optional parameter that, when specified, allows the given option to appear multiple times in theWITH
clause. This also converts the struct’s type from$t
toVec<$t>
.