use super::new_reader::NewReader;
#[derive(Default)]
pub struct BackendKeyData {
pub process_id: u32,
pub secret_key: u32,
}
impl BackendKeyData {
pub fn decode<Container: super::new_reader::ReaderContext>(
context: Container,
) -> Result<Self, bun_core::Error> {
Self::decode_internal(NewReader { wrapped: context })
}
pub fn decode_internal<Container: super::new_reader::ReaderContext>(
mut reader: NewReader<Container>,
) -> Result<Self, bun_core::Error> {
if !reader.expect_int::<u32>(12)? {
return Err(crate::postgres::AnyPostgresError::InvalidBackendKeyData.into());
}
Ok(Self {
process_id: reader.int4()?,
secret_key: reader.int4()?,
})
}
}