Struct postgres_cursor::Builder
[−]
[src]
pub struct Builder<'conn, 'builder, D: ?Sized + 'builder> { /* fields omitted */ }
Builds a Cursor
This type is constructed by calling Cursor::build
.
Methods
impl<'conn, 'builder, D: Display + ?Sized + 'builder> Builder<'conn, 'builder, D>
[src]
fn query_params(self, params: &'builder [&'builder ToSql]) -> Self
[src]
Set query params for cursor creation
fn batch_size(self, batch_size: u32) -> Self
[src]
Set the batch size passed to FETCH
on each iteration.
Default is 5,000.
fn tag<D2: Display + ?Sized>(
self,
tag: &'builder D2
) -> Builder<'conn, 'builder, D2>
[src]
self,
tag: &'builder D2
) -> Builder<'conn, '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(&conn) .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(&conn) .tag(&tag) .finalize();
fn query(self, query: &'builder str) -> Self
[src]
Set the query to create a cursor for.
Default is SELECT 1
.
fn finalize(self) -> Result<Cursor<'conn>>
[src]
Turn the builder into a Cursor
.