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