From d368475b50880b920ffbd73b7d6398b2171db53f Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Fri, 30 Dec 2022 13:47:41 +0200 Subject: [PATCH] Add flush() to front-end messages The PostgreSQL wire protocol has a "Flush" message, which can be used by the clients for long-lived connections. Add a flush() helper for it. --- postgres-protocol/src/message/frontend.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/postgres-protocol/src/message/frontend.rs b/postgres-protocol/src/message/frontend.rs index 5d0a8ff8..600f7da4 100644 --- a/postgres-protocol/src/message/frontend.rs +++ b/postgres-protocol/src/message/frontend.rs @@ -271,6 +271,12 @@ where }) } +#[inline] +pub fn flush(buf: &mut BytesMut) { + buf.put_u8(b'H'); + write_body(buf, |_| Ok::<(), io::Error>(())).unwrap(); +} + #[inline] pub fn sync(buf: &mut BytesMut) { buf.put_u8(b'S');