From 1e3ddd43bc3faf580cc64c93c851ca91f892ded0 Mon Sep 17 00:00:00 2001 From: Bojan Serafimov Date: Mon, 27 Dec 2021 23:04:56 -0500 Subject: [PATCH] Add struct for key data --- zenith_utils/src/pq_proto.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/zenith_utils/src/pq_proto.rs b/zenith_utils/src/pq_proto.rs index 9abb23747b..b5e40c66bc 100644 --- a/zenith_utils/src/pq_proto.rs +++ b/zenith_utils/src/pq_proto.rs @@ -52,6 +52,12 @@ pub enum StartupRequestCode { Normal, } +#[derive(Debug)] +pub struct CancelKeyData { + pub backend_pid: i32, + pub cancel_key: i32, +} + #[derive(Debug)] pub struct FeQueryMessage { pub body: Bytes, @@ -336,7 +342,7 @@ pub enum BeMessage<'a> { AuthenticationOk, AuthenticationMD5Password(&'a [u8; 4]), AuthenticationCleartextPassword, - BackendKeyData { backend_pid: i32, cancel_key: i32 }, + BackendKeyData(CancelKeyData), BindComplete, CommandComplete(&'a [u8]), CopyData(&'a [u8]), @@ -533,14 +539,11 @@ impl<'a> BeMessage<'a> { .unwrap(); // write into BytesMut can't fail } - BeMessage::BackendKeyData { - backend_pid, - cancel_key, - } => { + BeMessage::BackendKeyData(key_data) => { buf.put_u8(b'K'); write_body(buf, |buf| { - buf.put_i32(*backend_pid); - buf.put_i32(*cancel_key); + buf.put_i32(key_data.backend_pid); + buf.put_i32(key_data.cancel_key); Ok(()) }) .unwrap();