mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-25 09:28:39 +00:00
cargo fmt
This commit is contained in:
@@ -25,7 +25,7 @@ impl<'a> Encode for Describe<'a> {
|
|||||||
|
|
||||||
let len = 4 + self.name.len() + 1 + 4;
|
let len = 4 + self.name.len() + 1 + 4;
|
||||||
buf.extend_from_slice(&(len as i32).to_be_bytes());
|
buf.extend_from_slice(&(len as i32).to_be_bytes());
|
||||||
|
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
DescribeKind::Portal => buf.push(b'P'),
|
DescribeKind::Portal => buf.push(b'P'),
|
||||||
DescribeKind::PreparedStatement => buf.push(b'S'),
|
DescribeKind::PreparedStatement => buf.push(b'S'),
|
||||||
@@ -61,4 +61,4 @@ mod test {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
Authentication, BackendKeyData, CommandComplete, DataRow, Decode, NotificationResponse,
|
Authentication, BackendKeyData, CommandComplete, DataRow, Decode, NotificationResponse,
|
||||||
ParameterStatus, ReadyForQuery, Response, RowDescription, ParameterDescription,
|
ParameterDescription, ParameterStatus, ReadyForQuery, Response, RowDescription,
|
||||||
};
|
};
|
||||||
use byteorder::{BigEndian, ByteOrder};
|
use byteorder::{BigEndian, ByteOrder};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{Decode};
|
use crate::Decode;
|
||||||
use byteorder::{BigEndian, ByteOrder};
|
use byteorder::{BigEndian, ByteOrder};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
||||||
@@ -14,17 +14,17 @@ pub struct ParameterDescription {
|
|||||||
impl Decode for ParameterDescription {
|
impl Decode for ParameterDescription {
|
||||||
fn decode(src: Bytes) -> io::Result<Self> {
|
fn decode(src: Bytes) -> io::Result<Self> {
|
||||||
let count = BigEndian::read_u16(&*src) as usize;
|
let count = BigEndian::read_u16(&*src) as usize;
|
||||||
|
|
||||||
// todo: error handling
|
// todo: error handling
|
||||||
assert_eq!(src.len(), count * 4 + 2);
|
assert_eq!(src.len(), count * 4 + 2);
|
||||||
|
|
||||||
let mut ids = Vec::with_capacity(count);
|
let mut ids = Vec::with_capacity(count);
|
||||||
for i in 0..count {
|
for i in 0..count {
|
||||||
let offset = i * 4 + 2; // 4==size_of(u32), 2==size_of(u16)
|
let offset = i * 4 + 2; // 4==size_of(u32), 2==size_of(u16)
|
||||||
ids.push(BigEndian::read_u32(&src[offset..]));
|
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");
|
let src = Bytes::from_static(b"\x00\x00\x00\x01\x02\x03");
|
||||||
ParameterDescription::decode(src).unwrap();
|
ParameterDescription::decode(src).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ pub fn prepare<'a, 'b>(connection: &'a mut Connection, query: &'b str) -> Prepar
|
|||||||
|
|
||||||
let bind_state = proto::bind::header(&mut connection.wbuf, "", "", &[]);
|
let bind_state = proto::bind::header(&mut connection.wbuf, "", "", &[]);
|
||||||
|
|
||||||
Prepare { connection, bind_state, bind_values: 0 }
|
Prepare {
|
||||||
|
connection,
|
||||||
|
bind_state,
|
||||||
|
bind_values: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Prepare<'a> {
|
impl<'a> Prepare<'a> {
|
||||||
@@ -36,7 +40,12 @@ impl<'a> Prepare<'a> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub async fn execute(self) -> io::Result<u64> {
|
pub async fn execute(self) -> io::Result<u64> {
|
||||||
proto::bind::trailer(&mut self.connection.wbuf, self.bind_state, self.bind_values, &[]);
|
proto::bind::trailer(
|
||||||
|
&mut self.connection.wbuf,
|
||||||
|
self.bind_state,
|
||||||
|
self.bind_values,
|
||||||
|
&[],
|
||||||
|
);
|
||||||
|
|
||||||
self.connection.send(Execute::new("", 0));
|
self.connection.send(Execute::new("", 0));
|
||||||
self.connection.send(Sync);
|
self.connection.send(Sync);
|
||||||
|
|||||||
Reference in New Issue
Block a user