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
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Status {
    /** currently idle */
    Idle,
    /** a command is in progress */
    Active,
    /** idle, in a valid transaction block */
    InTrans,
    /** idle, in a failed transaction block */
    InError,
    /** reported if the connection is bad */
    Unknow,
}

#[doc(hidden)]
impl From<pq_sys::PGTransactionStatusType> for Status {
    fn from(status: pq_sys::PGTransactionStatusType) -> Self {
        match status {
            pq_sys::PGTransactionStatusType::PQTRANS_IDLE => Self::Idle,
            pq_sys::PGTransactionStatusType::PQTRANS_ACTIVE => Self::Active,
            pq_sys::PGTransactionStatusType::PQTRANS_INTRANS => Self::InTrans,
            pq_sys::PGTransactionStatusType::PQTRANS_INERROR => Self::InError,
            pq_sys::PGTransactionStatusType::PQTRANS_UNKNOWN => Self::Unknow,
        }
    }
}