[][src]Struct quaint::pooled::Quaint

pub struct Quaint {
    pub inner: Pool<QuaintManager>,
    // some fields omitted
}

The main entry point and an abstraction over database connections and

Fields

inner: Pool<QuaintManager>

Methods

impl Quaint[src]

pub async fn new<'_>(url_str: &'_ str) -> Result<Self>[src]

Create a new pool of connections to the database. The connection string follows the specified format:

connector_type://user:password@host/database?parameters

Connector type can be one of the following:

  • sqlite/file opens an SQLite connection
  • mysql opens a MySQL connection
  • postgres/postgresql opens a PostgreSQL connection

All parameters should be given in the query string format: ?key1=val1&key2=val2. All parameters are optional.

Common parameters:

  • connection_limit defines the number of connections opened to the database. If not set, defaults to the HikariCP Recommendation: physical_cpus * 2 + 1.

SQLite:

  • user/password do not do anything and can be emitted.
  • host should point to the database file.
  • db_name parameter should give a name to the database attached for query namespacing.
  • socket_timeout defined in seconds. Acts as the busy timeout in SQLite. When set, queries that are waiting for a lock to be released will return the Timeout error after the defined value.

PostgreSQL:

  • sslmode either disable, prefer or require. Read more
  • sslcert should point to a PEM certificate file.
  • sslidentity should point to a PKCS12 certificate database.
  • sslpassword the password to open the PKCS12 database.
  • sslaccept either strict or accept_invalid_certs. If strict, the certificate needs to be valid and in the CA certificates. accept_invalid_certs accepts any certificate from the server and can lead to weakened security. Defaults to accept_invalid_certs.
  • schema the default search path.
  • host additionally the host can be given as a parameter, typically in cases when connectiong to the database through a unix socket to separate the database name from the database path, such as postgresql:///dbname?host=/var/run/postgresql.
  • socket_timeout defined in seconds. If set, a query will return a Timeout error if it fails to resolve before given time.
  • connect_timeout defined in seconds (default: 5). Connecting to a database will return a ConnectTimeout error if taking more than the defined value.

MySQL:

  • sslcert should point to a PEM certificate file.
  • sslidentity should point to a PKCS12 certificate database.
  • sslpassword the password to open the PKCS12 database.
  • sslaccept either strict or accept_invalid_certs. If strict, the certificate needs to be valid and in the CA certificates. accept_invalid_certs accepts any certificate from the server and can lead to weakened security. Defaults to strict.
  • socket needed when connecting to MySQL database through a unix socket. When set, the host parameter is dismissed.
  • socket_timeout defined in seconds. If set, a query will return a Timeout error if it fails to resolve before given time.
  • connect_timeout defined in seconds (default: 5). Connecting to a database will return a ConnectTimeout error if taking more than the defined value.

pub async fn capacity<'_>(&'_ self) -> u32[src]

The number of connections in the pool.

pub async fn check_out<'_>(&'_ self) -> Result<PooledConnection>[src]

Reserve a connection from the pool.

pub fn connection_info(&self) -> &ConnectionInfo[src]

Info about the connection and underlying database.

Trait Implementations

impl Clone for Quaint[src]

Auto Trait Implementations

impl !RefUnwindSafe for Quaint

impl Send for Quaint

impl Sync for Quaint

impl Unpin for Quaint

impl !UnwindSafe for Quaint

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,