pub struct Connection { /* private fields */ }Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn connect(config: &DatabaseConfig) -> Result<Connection>
pub async fn connect(config: &DatabaseConfig) -> Result<Connection>
Open a connection and complete the startup handshake.
pub fn is_broken(&self) -> bool
Sourcepub fn in_transaction(&self) -> bool
pub fn in_transaction(&self) -> bool
True while a transaction is open, so the pool never hands back a connection that would leak one.
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Whether this connection is encrypted.
Sourcepub async fn simple_query(&mut self, sql: &str) -> Result<QueryResult>
pub async fn simple_query(&mut self, sql: &str) -> Result<QueryResult>
Run a statement with no parameters through the simple query protocol.
Used for DDL and for statements that must run as one unit, such as
begin/commit.
Sourcepub async fn query(
&mut self,
sql: &str,
params: &[Value],
) -> Result<QueryResult>
pub async fn query( &mut self, sql: &str, params: &[Value], ) -> Result<QueryResult>
Run a parameterised statement through the extended query protocol.
Parameters never enter the SQL text, so a value cannot change the shape of the statement — this is what makes SQL injection structurally impossible rather than a matter of remembering to escape.
Trait Implementations§
Source§impl DriverConnection for Connection
impl DriverConnection for Connection
Source§fn query<'a>(
&'a mut self,
sql: &'a str,
params: &'a [Value],
) -> BoxFuture<'a, Result<QueryResult>>
fn query<'a>( &'a mut self, sql: &'a str, params: &'a [Value], ) -> BoxFuture<'a, Result<QueryResult>>
Run a statement with bound parameters. Read more
Source§fn simple_query<'a>(
&'a mut self,
sql: &'a str,
) -> BoxFuture<'a, Result<QueryResult>>
fn simple_query<'a>( &'a mut self, sql: &'a str, ) -> BoxFuture<'a, Result<QueryResult>>
Run a statement with no parameters — DDL, and transaction control.
Source§fn is_broken(&self) -> bool
fn is_broken(&self) -> bool
Whether this connection is known to be unusable, so the pool discards it
instead of handing it to the next caller.
Source§fn in_transaction(&self) -> bool
fn in_transaction(&self) -> bool
Whether a transaction is still open. A connection left inside one must
never go back into rotation.
Auto Trait Implementations§
impl !Freeze for Connection
impl !RefUnwindSafe for Connection
impl !UnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
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