Rename CopyStream to CopyOutStream

This commit is contained in:
Steven Fackler 2019-11-30 16:17:23 -05:00
parent ff3ea1c9df
commit 299ef6c8dd
6 changed files with 15 additions and 15 deletions

View File

@ -3,11 +3,11 @@ use futures::executor;
use std::io::{self, BufRead, Cursor, Read};
use std::marker::PhantomData;
use std::pin::Pin;
use tokio_postgres::{CopyStream, Error};
use tokio_postgres::{CopyOutStream, Error};
/// The reader returned by the `copy_out` method.
pub struct CopyOutReader<'a> {
it: executor::BlockingStream<Pin<Box<CopyStream>>>,
it: executor::BlockingStream<Pin<Box<CopyOutStream>>>,
cur: Cursor<Bytes>,
_p: PhantomData<&'a mut ()>,
}
@ -18,7 +18,7 @@ impl Drop for CopyOutReader<'_> {
}
impl<'a> CopyOutReader<'a> {
pub(crate) fn new(stream: CopyStream) -> Result<CopyOutReader<'a>, Error> {
pub(crate) fn new(stream: CopyOutStream) -> Result<CopyOutReader<'a>, Error> {
let mut it = executor::block_on_stream(Box::pin(stream));
let cur = match it.next() {
Some(Ok(cur)) => cur,

View File

@ -8,7 +8,7 @@ use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use tokio_postgres::types::{IsNull, ToSql, Type, FromSql, WrongType};
use tokio_postgres::{CopyStream, CopyInSink};
use tokio_postgres::{CopyOutStream, CopyInSink};
use std::io::Cursor;
use byteorder::{ByteOrder, BigEndian};
@ -99,14 +99,14 @@ struct Header {
pin_project! {
pub struct BinaryCopyOutStream {
#[pin]
stream: CopyStream,
stream: CopyOutStream,
types: Arc<Vec<Type>>,
header: Option<Header>,
}
}
impl BinaryCopyOutStream {
pub fn new(types: &[Type], stream: CopyStream) -> BinaryCopyOutStream {
pub fn new(types: &[Type], stream: CopyOutStream) -> BinaryCopyOutStream {
BinaryCopyOutStream {
stream,
types: Arc::new(types.to_vec()),

View File

@ -3,7 +3,7 @@ use crate::cancel_query;
use crate::codec::BackendMessages;
use crate::config::{Host, SslMode};
use crate::connection::{Request, RequestMessages};
use crate::copy_out::CopyStream;
use crate::copy_out::CopyOutStream;
use crate::query::RowStream;
use crate::simple_query::SimpleQueryStream;
use crate::slice_iter;
@ -370,7 +370,7 @@ impl Client {
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<CopyStream, Error>
) -> Result<CopyOutStream, Error>
where
T: ?Sized + ToStatement,
{

View File

@ -15,14 +15,14 @@ pub async fn copy_out<'a, I>(
client: &InnerClient,
statement: Statement,
params: I,
) -> Result<CopyStream, Error>
) -> Result<CopyOutStream, Error>
where
I: IntoIterator<Item = &'a dyn ToSql>,
I::IntoIter: ExactSizeIterator,
{
let buf = query::encode(client, &statement, params)?;
let responses = start(client, buf).await?;
Ok(CopyStream {
Ok(CopyOutStream {
responses,
_p: PhantomPinned,
})
@ -46,14 +46,14 @@ async fn start(client: &InnerClient, buf: Bytes) -> Result<Responses, Error> {
pin_project! {
/// A stream of `COPY ... TO STDOUT` query data.
pub struct CopyStream {
pub struct CopyOutStream {
responses: Responses,
#[pin]
_p: PhantomPinned,
}
}
impl Stream for CopyStream {
impl Stream for CopyOutStream {
type Item = Result<Bytes, Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {

View File

@ -106,7 +106,7 @@ pub use crate::client::Client;
pub use crate::config::Config;
pub use crate::connection::Connection;
pub use crate::copy_in::CopyInSink;
pub use crate::copy_out::CopyStream;
pub use crate::copy_out::CopyOutStream;
use crate::error::DbError;
pub use crate::error::Error;
pub use crate::portal::Portal;

View File

@ -1,6 +1,6 @@
use crate::codec::FrontendMessage;
use crate::connection::RequestMessages;
use crate::copy_out::CopyStream;
use crate::copy_out::CopyOutStream;
use crate::query::RowStream;
#[cfg(feature = "runtime")]
use crate::tls::MakeTlsConnect;
@ -226,7 +226,7 @@ impl<'a> Transaction<'a> {
&self,
statement: &T,
params: &[&(dyn ToSql + Sync)],
) -> Result<CopyStream, Error>
) -> Result<CopyOutStream, Error>
where
T: ?Sized + ToStatement,
{