Skip to content

Commit 376deed

Browse files
committed
Finish frontend message rewrites
1 parent c4fa1c8 commit 376deed

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

src/message/frontend.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,6 @@ fn write_counted<I, T, F, E>(items: I, mut serializer: F, buf: &mut Vec<u8>) ->
8585
Ok(())
8686
}
8787

88-
/// A trait implemented by types serializable as frontend Postgres messages.
89-
pub trait Message {
90-
/// Serializes this message to a buffer.
91-
fn write(&self, buf: &mut Vec<u8>) -> Result<(), io::Error>;
92-
}
93-
9488
pub fn cancel_request(process_id: i32, secret_key: i32, buf: &mut Vec<u8>) {
9589
write_body(buf, |buf| {
9690
buf.write_i32::<BigEndian>(80877102).unwrap();
@@ -108,18 +102,13 @@ pub fn close(variant: u8, name: &str, buf: &mut Vec<u8>) -> io::Result<()> {
108102
})
109103
}
110104

111-
pub struct CopyData<'a> {
112-
pub data: &'a [u8],
113-
}
114-
115-
impl<'a> Message for CopyData<'a> {
116-
fn write(&self, buf: &mut Vec<u8>) -> Result<(), io::Error> {
117-
buf.push(b'd');
118-
write_body(buf, |buf| {
119-
buf.extend_from_slice(self.data);
120-
Ok(())
121-
})
122-
}
105+
// FIXME ideally this'd take a Read but it's unclear what to do at EOF
106+
pub fn copy_data(data: &[u8], buf: &mut Vec<u8>) -> io::Result<()> {
107+
buf.push(b'd');
108+
write_body(buf, |buf| {
109+
buf.extend_from_slice(data);
110+
Ok(())
111+
})
123112
}
124113

125114
pub fn copy_done(buf: &mut Vec<u8>) {

0 commit comments

Comments
 (0)