pub unsafe trait ScalarOut:
Send
+ Sync
+ 'static {
// Required methods
fn type_id() -> TypeId;
unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self);
}Expand description
A Rust type a scalar closure can return.
Implemented for every ScalarValue, plus String and Vec<u8> for
VARCHAR and BLOB results, and for Option<R> of any of them: None
writes SQL NULL for that row, so a closure can return NULL for some
non-NULL inputs.
§Safety
write performs an unchecked typed write into a vector’s
data buffer; see ScalarValue.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<R: ScalarOut> ScalarOut for Option<R>
None is SQL NULL.
impl<R: ScalarOut> ScalarOut for Option<R>
None is SQL NULL.
The column type is R’s; Some(v) writes v exactly as R would, and
None marks the row NULL through VectorWriter::set_null. This lets
map1 and its siblings return NULL for an
input that is not NULL — map1_str("domain", |s: &str| s.split_once('@') .map(|(_, d)| d.to_owned())) — without dropping to
scalar_callback!.
It does not change how NULL arguments are treated: the NULL-propagating
constructors still skip a row with a NULL argument and write NULL without
calling the closure. Use the *_opt constructors to see NULL arguments.