macro_rules! define_row_builder {
(
struct $name:ident<$lifetime:lifetime $(, $generic:ident: $bound:path )?>
$( where $where_path:path: $where_bound:path $(,)? )?
$({ $($field:ident: $field_type:ty),+ $(,)? })?,
|$array_param:ident| -> $array_type:ty { $init_expr:expr }
$(, |$value:ident| $(-> Option<$option_ty:ty>)? $value_transform:expr)?
) => { ... };
}
Expand description
Macro to define (possibly generic) row builders with consistent structure and behavior.
The macro optionally allows to define a transform for values read from the underlying
array. Transforms of the form |value| { ... }
are infallible (and should produce something
that implements Into<Variant>
), while transforms of the form |value| -> Option<_> { ... }
are fallible (and should produce Option<impl Into<Variant>>
); a failed tarnsform will either
append null to the builder or return an error, depending on cast options.
Also supports optional extra fields that are passed to the constructor and which are available
by reference in the value transform. Providing a fallible value transform requires also
providing the extra field options: &'a CastOptions
.