Macro connectorx::impl_typesystem

source ·
macro_rules! impl_typesystem {
    (
        system = $TS:tt,
        mappings = {
            $(
                { $($V:tt)|+ => $NT:ty }
            )*
        }
    ) => { ... };
    (@typeassoc $TS:tt [$($V:tt)+], $NT:ty) => { ... };
    (@realize $TS:tt $([ [$($V:tt)+] => $NT:ty ])+) => { ... };
}
Expand description

Associate physical representations to a typesystem.

§Example Usage

pub enum ArrowTypeSystem {
    Int32(bool),
    Int64(bool),
    UInt32(bool),
    UInt64(bool),
    Float32(bool),
    Float64(bool),
    Boolean(bool),
    LargeUtf8(bool),
    LargeBinary(bool),
    Date32(bool),
    Date64(bool),
    Time64(bool),
    DateTimeTz(bool),
}

impl_typesystem! {
    system = ArrowTypeSystem,
    mappings = {
        { Int32      => i32           }
        { Int64      => i64           }
        { UInt32     => u32           }
        { UInt64     => u64           }
        { Float64    => f64           }
        { Float32    => f32           }
        { Boolean    => bool          }
        { LargeUtf8  => String        }
        { LargeBinary => Vec<u8>      }
        { Date32     => NaiveDate     }
        { Date64     => NaiveDateTime }
        { Time64     => NaiveTime     }
        { DateTimeTz => DateTime<Utc> }
    }
}

This means for the type system ArrowTypeSystem, it’s variant ArrowTypeSystem::Int32(false) is corresponding to the physical type i32 and ArrowTypeSystem::Int32(true) is corresponding to the physical type Option<i32>.