Skip to main content

ScalarValue

Trait ScalarValue 

Source
pub unsafe trait ScalarValue:
    Copy
    + Send
    + Sync
    + 'static {
    // Required methods
    fn type_id() -> TypeId;
    unsafe fn read(reader: &VectorReader, row: usize) -> Self;
}
Expand description

A Rust type that maps 1:1 onto a DuckDB scalar column type.

Implemented for bool, every signed and unsigned integer width DuckDB has (i8..i128, u8..u128), and f32 / f64. These are the types the closure-based constructors accept as arguments.

§Safety

read performs an unchecked typed read of a vector’s data buffer. An implementation must return the type that type_id names, or reads will silently reinterpret memory. This is why the trait is unsafe to implement; using it is entirely safe.

Required Methods§

Source

fn type_id() -> TypeId

The DuckDB column type this maps to.

Source

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Reads row row of reader as Self.

§Safety

reader must cover a vector whose type is type_id, and row must be within its row count.

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 ScalarValue for bool

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for f32

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for f64

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for i8

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for i16

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for i32

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for i64

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for i128

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for u8

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for u16

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for u32

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for u64

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Source§

impl ScalarValue for u128

Source§

fn type_id() -> TypeId

Source§

unsafe fn read(reader: &VectorReader, row: usize) -> Self

Implementors§