1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
mod primitive;
pub use primitive::*;

mod chrono;
use crate::type_id::TypeId;
pub use chrono::*;

/// Rust primitive types to duckdb types
pub trait ToDuckDbType {
    const DUCKDB_TYPE_ID: TypeId;
    /// Representation to interface with DuckDb
    type DuckDbRepresentation;
    // /// Create a duckdb logical type structure for this type
    // fn logical_type() -> LogicalTypeHandle {
    //     unsafe { LogicalTypeHandle::from_id(Self::DUCKDB_TYPE_ID) }
    // }
}

pub trait IntoDuckDb
where
    Self: ToDuckDbType,
{
    /// Convert to DuckDb representation.
    /// # Panic
    /// If unrepresentable
    fn into_duckdb(self) -> Self::DuckDbRepresentation;
}
pub trait FromDuckDb
where
    Self: ToDuckDbType,
{
    /// Convert from DuckDb representation
    /// # Panic
    /// If unrepresentable
    fn from_duckdb(value: Self::DuckDbRepresentation) -> Self;
}