pub struct PostgresConnection { /* private fields */ }
Expand description
A connection to a PostgreSQL database using tokio-postgres
Implementations§
Source§impl PostgresConnection
impl PostgresConnection
Sourcepub async fn connect(
connection_string: impl Into<String>,
) -> Result<Self, PostgresError>
pub async fn connect( connection_string: impl Into<String>, ) -> Result<Self, PostgresError>
Create a new direct connection without using a pool
Sourcepub async fn with_connection<F, R, E>(
connection_string: impl Into<String>,
operation: F,
) -> Result<R, PostgresError>
pub async fn with_connection<F, R, E>( connection_string: impl Into<String>, operation: F, ) -> Result<R, PostgresError>
Execute a function with a direct connection and automatically close it after use This is the most efficient way to perform a one-off database operation
Trait Implementations§
Source§impl Clone for PostgresConnection
impl Clone for PostgresConnection
Source§fn clone(&self) -> PostgresConnection
fn clone(&self) -> PostgresConnection
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl TestDatabaseConnection for PostgresConnection
impl TestDatabaseConnection for PostgresConnection
fn connection_string(&self) -> String
Auto Trait Implementations§
impl Freeze for PostgresConnection
impl !RefUnwindSafe for PostgresConnection
impl Send for PostgresConnection
impl Sync for PostgresConnection
impl Unpin for PostgresConnection
impl !UnwindSafe for PostgresConnection
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