Struct diesel::pg::CopyToQuery

source ·
pub struct CopyToQuery<T, O> { /* private fields */ }
Expand description

The structure returned by copy_to

The load and the load_raw methods allow to receive the configured data from the database. If you don’t have any special needs you should prefer using the more convenient load method.

The with_* methods allow to configure the settings used for the copy statement.

Implementations§

source§

impl<T> CopyToQuery<T, NotSet>
where T: CopyTarget,

source

pub fn load<U, C>( self, conn: &mut C, ) -> QueryResult<impl Iterator<Item = QueryResult<U>> + '_>
where U: FromSqlRow<<U::SelectExpression as Expression>::SqlType, Pg> + Selectable<Pg>, U::SelectExpression: AppearsOnTable<T::Table> + CopyTarget<Table = T::Table>, C: ExecuteCopyToConnection,

Copy data from the database by returning an iterator of deserialized data

This function allows to easily load data from the database via a COPY TO statement. It does not allow to configure any settings via the with_* method, as it internally sets the required options itself. It will use the binary format to deserialize the result into the specified type U. Column selection is performed via Selectable.

source§

impl<T, O> CopyToQuery<T, O>
where O: CopyToMarker, T: CopyTarget,

source

pub fn load_raw<C>(self, conn: &mut C) -> QueryResult<impl BufRead + '_>
where C: ExecuteCopyToConnection,

Copy data from the database by directly accessing the provided response

This function returns a type that implements std::io::BufRead which allows to directly read the data as provided by the database. The exact format depends on what options are set via the various with_* methods.

source

pub fn with_format(self, format: CopyFormat) -> CopyToQuery<T, CopyToOptions>

The format used for the copy statement

See the PostgreSQL documentation for more details.

source

pub fn with_freeze(self, freeze: bool) -> CopyToQuery<T, CopyToOptions>

Whether or not the freeze option is set

See the PostgreSQL documentation for more details.

source

pub fn with_delimiter(self, delimiter: char) -> CopyToQuery<T, CopyToOptions>

Which delimiter should be used for textual output formats

See the PostgreSQL documentation for more details.

source

pub fn with_null(self, null: impl Into<String>) -> CopyToQuery<T, CopyToOptions>

Which string should be used in place of a NULL value for textual output formats

See the PostgreSQL documentation for more details.

source

pub fn with_quote(self, quote: char) -> CopyToQuery<T, CopyToOptions>

Which quote character should be used for textual output formats

See the PostgreSQL documentation for more details.

source

pub fn with_escape(self, escape: char) -> CopyToQuery<T, CopyToOptions>

Which escape character should be used for textual output formats

See the PostgreSQL documentation for more details.

source

pub fn with_header(self, set: bool) -> CopyToQuery<T, CopyToOptions>

Is a header provided as part of the textual input or not

See the PostgreSQL documentation for more details.

Trait Implementations§

source§

impl<T: Debug, O: Debug> Debug for CopyToQuery<T, O>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, O> Freeze for CopyToQuery<T, O>
where T: Freeze, O: Freeze,

§

impl<T, O> RefUnwindSafe for CopyToQuery<T, O>

§

impl<T, O> Send for CopyToQuery<T, O>
where T: Send, O: Send,

§

impl<T, O> Sync for CopyToQuery<T, O>
where T: Sync, O: Sync,

§

impl<T, O> Unpin for CopyToQuery<T, O>
where T: Unpin, O: Unpin,

§

impl<T, O> UnwindSafe for CopyToQuery<T, O>
where T: UnwindSafe, O: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoSql for T

source§

fn into_sql<T>(self) -> AsExprOf<Self, T>

Convert self to an expression for Diesel’s query builder. Read more
source§

fn as_sql<'a, T>(&'a self) -> AsExprOf<&'a Self, T>
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.