Skip to main content

Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }

Implementations§

Source§

impl Connection

Source

pub async fn connect(config: &DatabaseConfig) -> Result<Connection>

Open a connection and complete the startup handshake.

Source

pub fn is_broken(&self) -> bool

Source

pub fn in_transaction(&self) -> bool

True while a transaction is open, so the pool never hands back a connection that would leak one.

Source

pub fn is_encrypted(&self) -> bool

Whether this connection is encrypted.

Source

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.

Source

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.

Source

pub async fn close(self)

Ask the server to close the session politely.

Trait Implementations§

Source§

impl DriverConnection for Connection

Source§

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>>

Run a statement with no parameters — DDL, and transaction control.
Source§

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

Whether a transaction is still open. A connection left inside one must never go back into rotation.
Source§

fn close(self: Box<Self>) -> BoxFuture<'static, ()>

Say goodbye politely, then hang up.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.