Struct Builder

Source
pub struct Builder<'client, 'builder, D: ?Sized + 'builder> { /* private fields */ }
Expand description

Builds a Cursor

This type is constructed by calling Cursor::build.

Implementations§

Source§

impl<'client, 'builder, D: Display + ?Sized + 'builder> Builder<'client, 'builder, D>

Source

pub fn query_params( self, params: &'builder [&'builder (dyn ToSql + Sync)], ) -> Self

Set query params for cursor creation

Source

pub fn batch_size(self, batch_size: u32) -> Self

Set the batch size passed to FETCH on each iteration.

Default is 5,000.

Source

pub fn tag<D2: Display + ?Sized>( self, tag: &'builder D2, ) -> Builder<'client, 'builder, D2>

Set the tag for cursor name.

Adding a tag to the cursor name can be helpful for identifying where cursors originate when viewing pg_stat_activity.

Default is default.

§Examples

Any type that implements fmt::Display may be provided as a tag. For example, a simple string literal is one option.

let mut cursor = Cursor::build(&mut client)
    .tag("custom-cursor-tag")
    .finalize();

Or maybe you want to build a tag at run-time without incurring an extra allocation:

use std::fmt;

struct Pid(i32);
impl fmt::Display for Pid {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "pid-{}", self.0)
    }
}

let tag = Pid(8123);
let mut cursor = Cursor::build(&mut client)
    .tag(&tag)
    .finalize();
Source

pub fn query(self, query: &'builder str) -> Self

Set the query to create a cursor for.

Default is SELECT 1.

Source

pub fn finalize(self) -> Result<Cursor<'client>, Error>

Turn the builder into a Cursor.

Auto Trait Implementations§

§

impl<'client, 'builder, D> Freeze for Builder<'client, 'builder, D>
where D: ?Sized,

§

impl<'client, 'builder, D> !RefUnwindSafe for Builder<'client, 'builder, D>

§

impl<'client, 'builder, D> Send for Builder<'client, 'builder, D>
where D: Sync + ?Sized,

§

impl<'client, 'builder, D> !Sync for Builder<'client, 'builder, D>

§

impl<'client, 'builder, D> Unpin for Builder<'client, 'builder, D>
where D: ?Sized,

§

impl<'client, 'builder, D> !UnwindSafe for Builder<'client, 'builder, D>

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V