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
46
47
48
49
50
51
52
use crate::{pg_sys, FromDatum, IntoDatum};
#[derive(Debug, Clone, Copy)]
pub struct AnyArray {
datum: pg_sys::Datum,
typoid: pg_sys::Oid,
}
impl AnyArray {
pub fn datum(&self) -> pg_sys::Datum {
self.datum
}
pub fn oid(&self) -> pg_sys::Oid {
self.typoid
}
#[inline]
pub fn into<T: FromDatum>(&self) -> Option<T> {
unsafe { T::from_datum(self.datum(), false, self.oid()) }
}
}
impl FromDatum for AnyArray {
#[inline]
unsafe fn from_datum(
datum: pg_sys::Datum,
is_null: bool,
typoid: pg_sys::Oid,
) -> Option<AnyArray> {
if is_null {
None
} else {
Some(AnyArray { datum, typoid })
}
}
}
impl IntoDatum for AnyArray {
#[inline]
fn into_datum(self) -> Option<pg_sys::Datum> {
Some(self.datum)
}
fn type_oid() -> u32 {
pg_sys::ANYARRAYOID
}
}