Skip to content

Commit 9856c7b

Browse files
author
zach-com
committed
Replace impl From block
1 parent ef95f34 commit 9856c7b

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

postgres/src/client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ impl Client {
420420
self.connection.block_on(async {
421421
let trivial_query = inner_client.simple_query("");
422422
tokio::time::timeout(timeout, trivial_query)
423-
.await?
423+
.await
424+
.map_err(|_| Error::timeout())?
424425
.map(|_| ())
425426
})
426427
}

tokio-postgres/src/bind.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ where
2020
I: IntoIterator<Item = P>,
2121
I::IntoIter: ExactSizeIterator,
2222
{
23-
type BytesResult = Result<bytes::Bytes, Error>;
2423
let name = format!("p{}", NEXT_ID.fetch_add(1, Ordering::SeqCst));
25-
let buf = client.with_buf::<_, BytesResult>(|buf| {
24+
let buf = client.with_buf(|buf| {
2625
query::encode_bind(&statement, params, &name, buf)?;
2726
frontend::sync(buf);
2827
Ok(buf.split().freeze())

tokio-postgres/src/error/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use postgres_protocol::message::backend::{ErrorFields, ErrorResponseBody};
55
use std::error::{self, Error as _Error};
66
use std::fmt;
77
use std::io;
8-
use tokio::time::error::Elapsed;
98

109
pub use self::sqlstate::*;
1110

@@ -494,10 +493,9 @@ impl Error {
494493
pub(crate) fn connect(e: io::Error) -> Error {
495494
Error::new(Kind::Connect, Some(Box::new(e)))
496495
}
497-
}
498496

499-
impl From<Elapsed> for Error {
500-
fn from(_e: Elapsed) -> Error {
497+
#[doc(hidden)]
498+
pub fn timeout() -> Error {
501499
Error::new(Kind::Timeout, None)
502500
}
503501
}

tokio-postgres/src/query.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ pub async fn query_portal(
6161
portal: &Portal,
6262
max_rows: i32,
6363
) -> Result<RowStream, Error> {
64-
type BytesResult = Result<bytes::Bytes, Error>;
65-
let buf = client.with_buf::<_, BytesResult>(|buf| {
64+
let buf = client.with_buf(|buf| {
6665
frontend::execute(portal.name(), max_rows, buf).map_err(Error::encode)?;
6766
frontend::sync(buf);
6867
Ok(buf.split().freeze())

0 commit comments

Comments
 (0)