1#![warn(warnings)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3
4#[macro_use]
5mod ffi;
6
7pub mod connection;
8pub mod encrypt;
9pub mod errors;
10pub mod escape;
11pub mod lo;
12pub mod ping;
13#[cfg(feature = "v14")]
14pub mod pipeline;
15pub mod poll;
16#[cfg(unix)]
17pub mod print;
18pub mod result;
19pub mod ssl;
20pub mod state;
21pub mod transaction;
22pub mod types;
23
24#[cfg(feature = "v17")]
25mod cancel;
26mod control_visibility;
27mod encoding;
28mod format;
29mod oid;
30mod status;
31#[cfg(feature = "v14")]
32mod trace;
33mod verbosity;
34
35#[cfg(feature = "v17")]
36pub use cancel::Cancel;
37pub use connection::Connection;
38pub use control_visibility::ContextVisibility;
39pub use encoding::*;
40pub use format::*;
41pub use lo::LargeObject;
42pub use oid::*;
43#[deprecated(since = "4.1.0", note = "Uses PQResult instead")]
44pub use result::PQResult as Result;
45pub use result::PQResult;
46pub use state::State;
47pub use status::*;
48pub use types::Type;
49pub use verbosity::*;
50
51pub fn version() -> i32 {
57 unsafe { pq_sys::PQlibVersion() }
58}
59
60#[cfg(feature = "v17")]
66pub fn current_time_usec() -> i64 {
67 unsafe { pq_sys::PQgetCurrentTimeUSec() }
68}
69
70#[cfg(test)]
71mod test {
72 static INIT: std::sync::Once = std::sync::Once::new();
73
74 pub fn dsn() -> String {
75 std::env::var("PQ_DSN").unwrap_or_else(|_| "host=localhost".to_string())
76 }
77
78 pub fn new_conn() -> crate::Connection {
79 INIT.call_once(|| {
80 env_logger::init();
81 });
82
83 crate::Connection::new(&dsn()).unwrap()
84 }
85
86 #[test]
87 fn version() {
88 assert!(crate::version() > 0);
89 }
90}