sqlx_core_guts/postgres/
column.rs

1use crate::column::Column;
2use crate::ext::ustr::UStr;
3use crate::postgres::{PgTypeInfo, Postgres};
4
5#[derive(Debug, Clone)]
6#[cfg_attr(feature = "offline", derive(serde::Serialize, serde::Deserialize))]
7pub struct PgColumn {
8    pub(crate) ordinal: usize,
9    pub(crate) name: UStr,
10    pub(crate) type_info: PgTypeInfo,
11    #[cfg_attr(feature = "offline", serde(skip))]
12    pub(crate) relation_id: Option<i32>,
13    #[cfg_attr(feature = "offline", serde(skip))]
14    pub(crate) relation_attribute_no: Option<i16>,
15}
16
17impl crate::column::private_column::Sealed for PgColumn {}
18
19impl Column for PgColumn {
20    type Database = Postgres;
21
22    fn ordinal(&self) -> usize {
23        self.ordinal
24    }
25
26    fn name(&self) -> &str {
27        &*self.name
28    }
29
30    fn type_info(&self) -> &PgTypeInfo {
31        &self.type_info
32    }
33}
34
35#[cfg(feature = "any")]
36impl From<PgColumn> for crate::any::AnyColumn {
37    #[inline]
38    fn from(column: PgColumn) -> Self {
39        crate::any::AnyColumn {
40            type_info: column.type_info.clone().into(),
41            kind: crate::any::column::AnyColumnKind::Postgres(column),
42        }
43    }
44}