84 lines
1.5 KiB
Rust
84 lines
1.5 KiB
Rust
use std::{any::TypeId, borrow::Cow, num::NonZeroU32};
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum PostgresDatatype {
|
|
Bigint,
|
|
Bigserial,
|
|
Bit(Option<NonZeroU32>),
|
|
BitVarying(Option<NonZeroU32>),
|
|
Boolean,
|
|
Box,
|
|
Bytea,
|
|
Character(Option<NonZeroU32>),
|
|
CharacterVarying(Option<NonZeroU32>),
|
|
Cidr,
|
|
Circle,
|
|
Date,
|
|
DoublePrecision,
|
|
Inet,
|
|
Integer,
|
|
Interval(Option<IntervalFields>,Option<u8>),
|
|
Json,
|
|
Jsonb,
|
|
Line,
|
|
Lseg,
|
|
Macaddr,
|
|
Macaddr8,
|
|
Money,
|
|
Numeric(Option<NumericConfig>),
|
|
Path,
|
|
PgLsn,
|
|
PgSnapshot,
|
|
Point,
|
|
Polygon,
|
|
Real,
|
|
SmallInt,
|
|
SmallSerial,
|
|
Serial,
|
|
Text,
|
|
Time(Option<u8>),
|
|
TimeTz(Option<u8>),
|
|
Timestamp(Option<u8>),
|
|
TimestampTz(Option<u8>),
|
|
TsQuery,
|
|
TsVector,
|
|
TxidSnapshot,
|
|
Uuid,
|
|
Xml,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum IntervalFields {
|
|
Year,
|
|
Month,
|
|
Day,
|
|
Hour,
|
|
Minute,
|
|
Second,
|
|
YearToMonth,
|
|
DayToHour,
|
|
DayToMinute,
|
|
DayToSecond,
|
|
HourToMinute,
|
|
HourToSecond,
|
|
MinuteToSecond,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub enum NumericConfig {
|
|
Precision(u16),
|
|
PrecisionAndScale(u16, i16),
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct Table {
|
|
pub columns: Cow<'static, [Column]>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct Column {
|
|
pub postgres_name: Cow<'static, str>,
|
|
pub postgres_datatype: PostgresDatatype,
|
|
pub field_name: Cow<'static, str>,
|
|
pub rust_type_id: fn() -> TypeId,
|
|
}
|