#[non_exhaustive]pub enum FieldType {
}Expand description
字段类型标记(PostgreSQL)
与 MySQL 后端保持一致的字段类型枚举。Blob 在 PostgreSQL 中对应 BYTEA,
Json 对应 JSON/JSONB,其余沿用通用语义。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Standard
标准类型(无需特殊处理)
Bool
BOOLEAN 类型(空数组/全 NULL 数组需要它绑定为 bool[])
Json
JSON / JSONB 类型
Jsonb
JSONB 类型(插入时与 JSON 同样按原生 serde_json 值绑定)
DateTime
TIMESTAMP(无时区)类型
TimestampTz
TIMESTAMPTZ(带时区)类型
Date
DATE 类型
Time
TIME 类型
Uuid
UUID 类型
Timestamp
以整数存储的时间戳
Decimal
NUMERIC / DECIMAL 类型
Blob
BYTEA 类型
Text
TEXT 类型
Array(Box<FieldType>)
数组类型(元素类型递归描述,如 TEXT[] → Array(Box::new(Text)))
Inet
INET:IPv4/IPv6 主机地址或网络地址
Cidr
CIDR:IPv4/IPv6 网络段
MacAddr
MACADDR:6 字节 MAC 地址
MacAddr8
MACADDR8:8 字节 MAC 地址(PostgreSQL 10+)
Bit
BIT:定长位串
Varbit
VARBIT:变长位串
Range(Box<FieldType>)
范围类型(RANGE):元素类型递归描述,如 int4range → Range(Standard)、
tsrange → Range(DateTime)。
无整数宽度提示的 FieldType::Standard 视为 PostgreSQL 默认的 32 位整数
范围 int4range;其余可映射元素类型见 FieldType::postgres_type_name。
Multirange(Box<FieldType>)
多范围类型(MULTIRANGE,PostgreSQL 14+):元素类型递归描述,
如 int4multirange → Multirange(Standard)。
Implementations§
Source§impl FieldType
impl FieldType
Sourcepub fn postgres_type_name(&self) -> Option<String>
pub fn postgres_type_name(&self) -> Option<String>
返回该字段类型对应的 PostgreSQL 类型名(format_type 风格,如
integer、text[]),用于 DDL 生成与类型核对。
FieldType::Standard 表示没有额外类型提示,返回 None;数组按
递归元素类型追加 [](元素类型未知时同样返回 None)。
Trait Implementations§
impl StructuralPartialEq for FieldType
Auto Trait Implementations§
impl Forget for FieldType
impl Freeze for FieldType
impl Move for FieldType
impl RefUnwindSafe for FieldType
impl Send for FieldType
impl Sync for FieldType
impl Unpin for FieldType
impl UnsafeUnpin for FieldType
impl UnwindSafe for FieldType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more