Rename CopyStream to CopyOutStream
This commit is contained in:
parent
ff3ea1c9df
commit
299ef6c8dd
@ -3,11 +3,11 @@ use futures::executor;
|
|||||||
use std::io::{self, BufRead, Cursor, Read};
|
use std::io::{self, BufRead, Cursor, Read};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use tokio_postgres::{CopyStream, Error};
|
use tokio_postgres::{CopyOutStream, Error};
|
||||||
|
|
||||||
/// The reader returned by the `copy_out` method.
|
/// The reader returned by the `copy_out` method.
|
||||||
pub struct CopyOutReader<'a> {
|
pub struct CopyOutReader<'a> {
|
||||||
it: executor::BlockingStream<Pin<Box<CopyStream>>>,
|
it: executor::BlockingStream<Pin<Box<CopyOutStream>>>,
|
||||||
cur: Cursor<Bytes>,
|
cur: Cursor<Bytes>,
|
||||||
_p: PhantomData<&'a mut ()>,
|
_p: PhantomData<&'a mut ()>,
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ impl Drop for CopyOutReader<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CopyOutReader<'a> {
|
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 mut it = executor::block_on_stream(Box::pin(stream));
|
||||||
let cur = match it.next() {
|
let cur = match it.next() {
|
||||||
Some(Ok(cur)) => cur,
|
Some(Ok(cur)) => cur,
|
||||||
|
@ -8,7 +8,7 @@ use std::pin::Pin;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
use tokio_postgres::types::{IsNull, ToSql, Type, FromSql, WrongType};
|
use tokio_postgres::types::{IsNull, ToSql, Type, FromSql, WrongType};
|
||||||
use tokio_postgres::{CopyStream, CopyInSink};
|
use tokio_postgres::{CopyOutStream, CopyInSink};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use byteorder::{ByteOrder, BigEndian};
|
use byteorder::{ByteOrder, BigEndian};
|
||||||
|
|
||||||
@ -99,14 +99,14 @@ struct Header {
|
|||||||
pin_project! {
|
pin_project! {
|
||||||
pub struct BinaryCopyOutStream {
|
pub struct BinaryCopyOutStream {
|
||||||
#[pin]
|
#[pin]
|
||||||
stream: CopyStream,
|
stream: CopyOutStream,
|
||||||
types: Arc<Vec<Type>>,
|
types: Arc<Vec<Type>>,
|
||||||
header: Option<Header>,
|
header: Option<Header>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BinaryCopyOutStream {
|
impl BinaryCopyOutStream {
|
||||||
pub fn new(types: &[Type], stream: CopyStream) -> BinaryCopyOutStream {
|
pub fn new(types: &[Type], stream: CopyOutStream) -> BinaryCopyOutStream {
|
||||||
BinaryCopyOutStream {
|
BinaryCopyOutStream {
|
||||||
stream,
|
stream,
|
||||||
types: Arc::new(types.to_vec()),
|
types: Arc::new(types.to_vec()),
|
||||||
|
@ -3,7 +3,7 @@ use crate::cancel_query;
|
|||||||
use crate::codec::BackendMessages;
|
use crate::codec::BackendMessages;
|
||||||
use crate::config::{Host, SslMode};
|
use crate::config::{Host, SslMode};
|
||||||
use crate::connection::{Request, RequestMessages};
|
use crate::connection::{Request, RequestMessages};
|
||||||
use crate::copy_out::CopyStream;
|
use crate::copy_out::CopyOutStream;
|
||||||
use crate::query::RowStream;
|
use crate::query::RowStream;
|
||||||
use crate::simple_query::SimpleQueryStream;
|
use crate::simple_query::SimpleQueryStream;
|
||||||
use crate::slice_iter;
|
use crate::slice_iter;
|
||||||
@ -370,7 +370,7 @@ impl Client {
|
|||||||
&self,
|
&self,
|
||||||
statement: &T,
|
statement: &T,
|
||||||
params: &[&(dyn ToSql + Sync)],
|
params: &[&(dyn ToSql + Sync)],
|
||||||
) -> Result<CopyStream, Error>
|
) -> Result<CopyOutStream, Error>
|
||||||
where
|
where
|
||||||
T: ?Sized + ToStatement,
|
T: ?Sized + ToStatement,
|
||||||
{
|
{
|
||||||
|
@ -15,14 +15,14 @@ pub async fn copy_out<'a, I>(
|
|||||||
client: &InnerClient,
|
client: &InnerClient,
|
||||||
statement: Statement,
|
statement: Statement,
|
||||||
params: I,
|
params: I,
|
||||||
) -> Result<CopyStream, Error>
|
) -> Result<CopyOutStream, Error>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = &'a dyn ToSql>,
|
I: IntoIterator<Item = &'a dyn ToSql>,
|
||||||
I::IntoIter: ExactSizeIterator,
|
I::IntoIter: ExactSizeIterator,
|
||||||
{
|
{
|
||||||
let buf = query::encode(client, &statement, params)?;
|
let buf = query::encode(client, &statement, params)?;
|
||||||
let responses = start(client, buf).await?;
|
let responses = start(client, buf).await?;
|
||||||
Ok(CopyStream {
|
Ok(CopyOutStream {
|
||||||
responses,
|
responses,
|
||||||
_p: PhantomPinned,
|
_p: PhantomPinned,
|
||||||
})
|
})
|
||||||
@ -46,14 +46,14 @@ async fn start(client: &InnerClient, buf: Bytes) -> Result<Responses, Error> {
|
|||||||
|
|
||||||
pin_project! {
|
pin_project! {
|
||||||
/// A stream of `COPY ... TO STDOUT` query data.
|
/// A stream of `COPY ... TO STDOUT` query data.
|
||||||
pub struct CopyStream {
|
pub struct CopyOutStream {
|
||||||
responses: Responses,
|
responses: Responses,
|
||||||
#[pin]
|
#[pin]
|
||||||
_p: PhantomPinned,
|
_p: PhantomPinned,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stream for CopyStream {
|
impl Stream for CopyOutStream {
|
||||||
type Item = Result<Bytes, Error>;
|
type Item = Result<Bytes, Error>;
|
||||||
|
|
||||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||||
|
@ -106,7 +106,7 @@ pub use crate::client::Client;
|
|||||||
pub use crate::config::Config;
|
pub use crate::config::Config;
|
||||||
pub use crate::connection::Connection;
|
pub use crate::connection::Connection;
|
||||||
pub use crate::copy_in::CopyInSink;
|
pub use crate::copy_in::CopyInSink;
|
||||||
pub use crate::copy_out::CopyStream;
|
pub use crate::copy_out::CopyOutStream;
|
||||||
use crate::error::DbError;
|
use crate::error::DbError;
|
||||||
pub use crate::error::Error;
|
pub use crate::error::Error;
|
||||||
pub use crate::portal::Portal;
|
pub use crate::portal::Portal;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::codec::FrontendMessage;
|
use crate::codec::FrontendMessage;
|
||||||
use crate::connection::RequestMessages;
|
use crate::connection::RequestMessages;
|
||||||
use crate::copy_out::CopyStream;
|
use crate::copy_out::CopyOutStream;
|
||||||
use crate::query::RowStream;
|
use crate::query::RowStream;
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
use crate::tls::MakeTlsConnect;
|
use crate::tls::MakeTlsConnect;
|
||||||
@ -226,7 +226,7 @@ impl<'a> Transaction<'a> {
|
|||||||
&self,
|
&self,
|
||||||
statement: &T,
|
statement: &T,
|
||||||
params: &[&(dyn ToSql + Sync)],
|
params: &[&(dyn ToSql + Sync)],
|
||||||
) -> Result<CopyStream, Error>
|
) -> Result<CopyOutStream, Error>
|
||||||
where
|
where
|
||||||
T: ?Sized + ToStatement,
|
T: ?Sized + ToStatement,
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user