#[non_exhaustive]pub struct CopyOut<'a> { /* private fields */ }Expand description
A reader for a COPY OUT operation.
Created via Connection::copy_out. Data is received from the server
in chunks.
Implementations§
Source§impl<'a> CopyOut<'a>
impl<'a> CopyOut<'a>
Sourcepub fn format(&self) -> u8
pub fn format(&self) -> u8
The overall format code for this COPY operation.
0 = text, 1 = binary.
Sourcepub fn column_formats(&self) -> &[u16]
pub fn column_formats(&self) -> &[u16]
Per-column format codes.
Sourcepub async fn read_next(&mut self) -> Result<Option<Vec<u8>>>
pub async fn read_next(&mut self) -> Result<Option<Vec<u8>>>
Read the next chunk of COPY data.
Returns None when the server has finished sending data.
Sourcepub async fn read_all(&mut self) -> Result<Vec<u8>>
pub async fn read_all(&mut self) -> Result<Vec<u8>>
Read all remaining COPY data into a single buffer.
Sourcepub async fn for_each<F>(&mut self, f: F) -> Result<()>
pub async fn for_each<F>(&mut self, f: F) -> Result<()>
Process each chunk with a callback (streaming).
Sourcepub async fn for_each_row<F>(&mut self, f: F) -> Result<()>
pub async fn for_each_row<F>(&mut self, f: F) -> Result<()>
Process each text-format row with a callback.
This is a convenience method for text-format COPY OUT operations.
It collects all data, splits by newlines, and calls f for each
row’s tab-separated fields.
§Example
let mut copy = conn.copy_out("COPY users TO STDOUT").await?;
copy.for_each_row(|fields| {
println!("id={}, name={}", fields[0], fields[1]);
Ok(())
}).await?;Sourcepub async fn for_each_csv_row<F>(
&mut self,
delimiter: char,
quote: char,
f: F,
) -> Result<()>
pub async fn for_each_csv_row<F>( &mut self, delimiter: char, quote: char, f: F, ) -> Result<()>
Process each CSV-format row with a callback.
This is a convenience method for CSV-format COPY OUT operations. It collects all data, splits by newlines, and parses each row as a simple CSV line (handling quoted fields with the specified delimiter and quote character).
§Example
let mut copy = conn.copy_out("COPY users TO STDOUT WITH (FORMAT csv)").await?;
copy.for_each_csv_row(',', '"', |fields| {
println!("id={}, name={}", fields[0], fields[1]);
Ok(())
}).await?;