fraiseql_wire/util/oid.rs
1//! Postgres Object Identifier (OID) constants
2//!
3//! OIDs identify data types in the Postgres wire protocol.
4
5/// Postgres type OID
6pub type OID = u32;
7
8/// JSON type OID
9pub const JSON_OID: OID = 114;
10
11/// JSONB type OID
12pub const JSONB_OID: OID = 3802;
13
14/// Check if an OID represents a JSON type
15#[inline]
16pub const fn is_json_oid(oid: OID) -> bool {
17 oid == JSON_OID || oid == JSONB_OID
18}
19
20#[cfg(test)]
21mod tests {
22 use super::*;
23
24 #[test]
25 fn test_json_oids() {
26 assert!(is_json_oid(JSON_OID));
27 assert!(is_json_oid(JSONB_OID));
28 assert!(!is_json_oid(23)); // INT4
29 }
30}