diff --git a/tokio-postgres/src/lib.rs b/tokio-postgres/src/lib.rs index 5fdd9fce..27dd6614 100644 --- a/tokio-postgres/src/lib.rs +++ b/tokio-postgres/src/lib.rs @@ -99,7 +99,8 @@ impl Client { pub fn copy_in(&mut self, statement: &Statement, params: &[&ToSql], stream: S) -> CopyIn where - S: Stream>, + S: Stream, + S::Item: AsRef<[u8]>, S::Error: Into>, { CopyIn(self.0.copy_in(&statement.0, params, stream)) @@ -239,7 +240,8 @@ impl Stream for Query { #[must_use = "futures do nothing unless polled"] pub struct CopyIn(proto::CopyInFuture) where - S: Stream>, + S: Stream, + S::Item: AsRef<[u8]>, S::Error: Into>; impl Future for CopyIn diff --git a/tokio-postgres/src/proto/client.rs b/tokio-postgres/src/proto/client.rs index 4ceb922a..eca8956b 100644 --- a/tokio-postgres/src/proto/client.rs +++ b/tokio-postgres/src/proto/client.rs @@ -142,7 +142,8 @@ impl Client { pub fn copy_in(&self, statement: &Statement, params: &[&ToSql], stream: S) -> CopyInFuture where - S: Stream>, + S: Stream, + S::Item: AsRef<[u8]>, S::Error: Into>, { let (mut sender, receiver) = mpsc::channel(0); diff --git a/tokio-postgres/src/proto/copy_in.rs b/tokio-postgres/src/proto/copy_in.rs index 12fc69ab..cec324d2 100644 --- a/tokio-postgres/src/proto/copy_in.rs +++ b/tokio-postgres/src/proto/copy_in.rs @@ -63,7 +63,8 @@ impl Stream for CopyInReceiver { #[derive(StateMachineFuture)] pub enum CopyIn where - S: Stream>, + S: Stream, + S::Item: AsRef<[u8]>, S::Error: Into>, { #[state_machine_future(start, transitions(ReadCopyInResponse))] @@ -102,7 +103,8 @@ where impl PollCopyIn for CopyIn where - S: Stream>, + S: Stream, + S::Item: AsRef<[u8]>, S::Error: Into>, { fn poll_start<'a>(state: &'a mut RentToOwn<'a, Start>) -> Poll, Error> { @@ -150,7 +152,7 @@ where None => match try_ready!(state.stream.poll().map_err(error::__user)) { Some(data) => { let mut buf = vec![]; - frontend::copy_data(&data, &mut buf).map_err(error::io)?; + frontend::copy_data(data.as_ref(), &mut buf).map_err(error::io)?; CopyMessage::Data(buf) } None => { @@ -204,7 +206,8 @@ where impl CopyInFuture where - S: Stream>, + S: Stream, + S::Item: AsRef<[u8]>, S::Error: Into>, { pub fn new(