Struct PgCopyIn
pub struct PgCopyIn<C>where
C: DerefMut<Target = PgConnection>,{ /* private fields */ }Expand description
A connection in streaming COPY FROM STDIN mode.
Created by PgConnection::copy_in_raw or Pool::copy_out_raw.
§Note
PgCopyIn::finish or PgCopyIn::abort must be called when finished or the connection will return an error the next time it is used.
Implementations§
§impl<C> PgCopyIn<C>where
C: DerefMut<Target = PgConnection>,
impl<C> PgCopyIn<C>where
C: DerefMut<Target = PgConnection>,
pub fn is_textual(&self) -> bool
pub fn is_textual(&self) -> bool
Returns true if Postgres is expecting data in text or CSV format.
pub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
Returns the number of columns expected in the input.
pub fn column_is_textual(&self, column: usize) -> bool
pub fn column_is_textual(&self, column: usize) -> bool
Check if a column is expecting data in text format (true) or binary format (false).
§Panics
If column is out of range according to .num_columns().
pub async fn send(
&mut self,
data: impl Deref<Target = [u8]>,
) -> Result<&mut PgCopyIn<C>, Error>
pub async fn send( &mut self, data: impl Deref<Target = [u8]>, ) -> Result<&mut PgCopyIn<C>, Error>
Send a chunk of COPY data.
The data is sent in chunks if it exceeds the maximum length of a CopyData message (1 GiB - 6
bytes) and may be partially sent if this call is cancelled.
If you’re copying data from an AsyncRead, maybe consider Self::read_from instead.
pub async fn read_from(
&mut self,
source: impl AsyncRead + Unpin,
) -> Result<&mut PgCopyIn<C>, Error>
pub async fn read_from( &mut self, source: impl AsyncRead + Unpin, ) -> Result<&mut PgCopyIn<C>, Error>
Copy data directly from source to the database without requiring an intermediate buffer.
source will be read to the end.
§Note: Completion Step Required
You must still call either Self::finish or Self::abort to complete the process.
§Note: Runtime Features
This method uses the AsyncRead trait which is re-exported from either Tokio or async-std
depending on which runtime feature is used.
The runtime features used to be mutually exclusive, but are no longer.
If both runtime-async-std and runtime-tokio features are enabled, the Tokio version
takes precedent.
pub async fn abort(self, msg: impl Into<String>) -> Result<(), Error>
pub async fn abort(self, msg: impl Into<String>) -> Result<(), Error>
Signal that the COPY process should be aborted and any data received should be discarded.
The given message can be used for indicating the reason for the abort in the database logs.
The server is expected to respond with an error, so only unexpected errors are returned.
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for PgCopyIn<C>where
C: Freeze,
impl<C> RefUnwindSafe for PgCopyIn<C>where
C: RefUnwindSafe,
impl<C> Send for PgCopyIn<C>where
C: Send,
impl<C> Sync for PgCopyIn<C>where
C: Sync,
impl<C> Unpin for PgCopyIn<C>where
C: Unpin,
impl<C> UnsafeUnpin for PgCopyIn<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for PgCopyIn<C>where
C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);