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
37
38
39
40
41
42
43
44
45
#![allow(non_camel_case_types)]
use crate as pg_sys;
use crate::PgBuiltInOids;
impl PgBuiltInOids {
pub fn value(self) -> pg_sys::Oid {
self as isize as pg_sys::Oid
}
pub fn oid(self) -> PgOid {
PgOid::from(self.value())
}
}
#[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Debug)]
pub enum PgOid {
InvalidOid,
Custom(pg_sys::Oid),
BuiltIn(PgBuiltInOids),
}
impl PgOid {
#[inline]
pub fn from(oid: pg_sys::Oid) -> PgOid {
match oid {
pg_sys::InvalidOid => PgOid::InvalidOid,
custom_oid => match PgBuiltInOids::from(oid) {
Some(builtin) => PgOid::BuiltIn(builtin),
None => PgOid::Custom(custom_oid),
},
}
}
#[inline]
pub fn value(self) -> pg_sys::Oid {
match self {
PgOid::InvalidOid => pg_sys::InvalidOid,
PgOid::Custom(custom) => custom,
PgOid::BuiltIn(builtin) => builtin.value(),
}
}
}