Connection

Trait Connection 

Source
pub trait Connection: 'static + Send {
    type Options: ConnectOptions<Connection = Self>;

    // Required methods
    fn close(self) -> BoxFuture<'static, Result<(), Error>>;
    fn close_hard(self) -> BoxFuture<'static, Result<(), Error>>;
    fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>>;
}

Required Associated Types§

Source

type Options: ConnectOptions<Connection = Self>

Required Methods§

Source

fn close(self) -> BoxFuture<'static, Result<(), Error>>

Explicitly close this database connection.

This notifies the database server that the connection is closing so that it can free up any server-side resources in use.

While connections can simply be dropped to clean up local resources, the Drop handler itself cannot notify the server that the connection is being closed because that may require I/O to send a termination message. That can result in a delay before the server learns that the connection is gone, usually from a TCP keepalive timeout.

Creating and dropping many connections in short order without calling .close() may lead to errors from the database server because those senescent connections will still count against any connection limit or quota that is configured.

Therefore it is recommended to call .close() on a connection when you are done using it and to .await the result to ensure the termination message is sent.

Source

fn close_hard(self) -> BoxFuture<'static, Result<(), Error>>

Source

fn ping(&mut self) -> BoxFuture<'_, Result<(), Error>>

Implementors§