Skip to main content

ScalarOut

Trait ScalarOut 

Source
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§

Source

fn type_id() -> TypeId

The DuckDB column type this maps to.

Source

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Writes value into row row of writer.

§Safety

writer must cover a vector whose type is type_id, and row must be within its capacity.

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 ScalarOut for String

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for Vec<u8>

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for bool

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for f32

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for f64

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for i8

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for i16

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for i32

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for i64

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for i128

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for u8

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for u16

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for u32

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for u64

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

impl ScalarOut for u128

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Source§

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.

Source§

fn type_id() -> TypeId

Source§

unsafe fn write(writer: &mut VectorWriter, row: usize, value: Self)

Implementors§