elefant_client/types/
oid.rs1use crate::protocol::FieldDescription;
2use crate::{
3 impl_from_sql_for_domain_type, DomainType, FromSqlBase, FromSqlBinary, FromSqlText,
4 PostgresType,
5};
6use std::error::Error;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct Oid(pub i32);
10
11impl DomainType for Oid {
12 type Inner = i32;
13
14 fn from_inner(inner: Self::Inner) -> Self {
15 Oid(inner)
16 }
17
18 fn accepts_postgres_type(oid: i32) -> bool {
19 oid == PostgresType::OID.oid
20 }
21}
22
23impl_from_sql_for_domain_type!(Oid);
24
25#[cfg(test)]
26mod tests {
27 #[cfg(feature = "tokio")]
28 mod tokio_connection {
29 use crate::test_helpers::get_tokio_test_client;
30 use crate::Oid;
31
32 #[tokio::test]
33 async fn handles_oid() {
34 let mut client = get_tokio_test_client().await;
35
36 let oid: Oid = client.read_single_value_dual_mode("select '26'::oid").await;
37
38 assert_eq!(oid, Oid(26));
39 }
40 }
41}