Struct scooby::postgres::tools::Parameters
source · pub struct Parameters { /* private fields */ }
Expand description
Generator of PostgreSQL parameter placeholders for dynamic statements with multiple values
Example
use scooby::postgres::Parameters;
let mut params = Parameters::new();
let p1 = params.next();
let p2 = params.next();
let p345 = params.next_n(3);
let p67 = params.next_array::<2>();
assert_eq!(p1, "$1");
assert_eq!(p2, "$2");
assert_eq!(p345, "$3, $4, $5");
assert_eq!(p67, ["$6", "$7"]);
Implementations§
source§impl Parameters
impl Parameters
sourcepub fn new() -> Parameters
pub fn new() -> Parameters
Make a new Parameters counter, starting with 1
sourcepub fn starting_from(first: usize) -> Parameters
pub fn starting_from(first: usize) -> Parameters
Make a new Parameters counter, starting with passed number
sourcepub fn next(&mut self) -> String
pub fn next(&mut self) -> String
Return the current parameter placeholder in $x
format, and increase the internal counter
sourcepub fn next_array<const N: usize>(&mut self) -> [String; N]
pub fn next_array<const N: usize>(&mut self) -> [String; N]
Return N next placeholders as an array of size N
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Parameters
impl Send for Parameters
impl Sync for Parameters
impl Unpin for Parameters
impl UnwindSafe for Parameters
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more