cargo fmt

This commit is contained in:
Zachery Gyurkovitz
2019-07-18 11:59:33 -07:00
parent 3f8508c0a4
commit 6e7b18bc00
4 changed files with 19 additions and 10 deletions

View File

@@ -25,7 +25,7 @@ impl<'a> Encode for Describe<'a> {
let len = 4 + self.name.len() + 1 + 4;
buf.extend_from_slice(&(len as i32).to_be_bytes());
match &self.kind {
DescribeKind::Portal => buf.push(b'P'),
DescribeKind::PreparedStatement => buf.push(b'S'),
@@ -61,4 +61,4 @@ mod test {
Ok(())
}
}
}

View File

@@ -1,6 +1,6 @@
use crate::{
Authentication, BackendKeyData, CommandComplete, DataRow, Decode, NotificationResponse,
ParameterStatus, ReadyForQuery, Response, RowDescription, ParameterDescription,
ParameterDescription, ParameterStatus, ReadyForQuery, Response, RowDescription,
};
use byteorder::{BigEndian, ByteOrder};
use bytes::BytesMut;

View File

@@ -1,4 +1,4 @@
use crate::{Decode};
use crate::Decode;
use byteorder::{BigEndian, ByteOrder};
use bytes::Bytes;
@@ -14,17 +14,17 @@ pub struct ParameterDescription {
impl Decode for ParameterDescription {
fn decode(src: Bytes) -> io::Result<Self> {
let count = BigEndian::read_u16(&*src) as usize;
// todo: error handling
assert_eq!(src.len(), count * 4 + 2);
let mut ids = Vec::with_capacity(count);
for i in 0..count {
let offset = i * 4 + 2; // 4==size_of(u32), 2==size_of(u16)
ids.push(BigEndian::read_u32(&src[offset..]));
}
Ok(ParameterDescription {ids})
Ok(ParameterDescription { ids })
}
}
@@ -61,4 +61,4 @@ mod test {
let src = Bytes::from_static(b"\x00\x00\x00\x01\x02\x03");
ParameterDescription::decode(src).unwrap();
}
}
}