1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
use crate::io::BufMut;
use crate::postgres::protocol::Encode;

#[derive(Copy, Clone, PartialOrd, PartialEq, Eq, Hash)]
pub struct StatementId(pub u32);

impl Encode for StatementId {
    fn encode(&self, buf: &mut Vec<u8>) {
        if self.0 != 0 {
            buf.put_str("__sqlx_statement_");

            // TODO: Use [itoa]
            buf.put_str_nul(&self.0.to_string());
        } else {
            buf.put_str_nul("");
        }
    }
}