[][src]Struct deadpool_postgres::config::Config

pub struct Config {
    pub user: Option<String>,
    pub password: Option<String>,
    pub dbname: Option<String>,
    pub options: Option<String>,
    pub application_name: Option<String>,
    pub ssl_mode: Option<SslMode>,
    pub host: Option<String>,
    pub hosts: Option<Vec<String>>,
    pub port: Option<u16>,
    pub ports: Option<Vec<u16>>,
    pub connect_timeout: Option<Duration>,
    pub keepalives: Option<bool>,
    pub keepalives_idle: Option<Duration>,
    pub target_session_attrs: Option<TargetSessionAttrs>,
    pub channel_binding: Option<ChannelBinding>,
    pub manager: Option<ManagerConfig>,
    pub pool: Option<PoolConfig>,
}

Configuration object. By enabling the config feature you can read the configuration using the config crate.

Example environment

PG_HOST=pg.example.com
PG_USER=john_doe
PG_PASSWORD=topsecret
PG_DBNAME=example
PG_POOL.MAX_SIZE=16
PG_POOL.TIMEOUTS.WAIT.SECS=5
PG_POOL.TIMEOUTS.WAIT.NANOS=0

Example usage

This example is not tested
Config::from_env("PG");

Fields

user: Option<String>

See tokio_postgres::Config::user

password: Option<String>

See tokio_postgres::Config::password

dbname: Option<String>

See tokio_postgres::Config::dbname

options: Option<String>

See tokio_postgres::Config::options

application_name: Option<String>

See tokio_postgres::Config::application_name

ssl_mode: Option<SslMode>

See tokio_postgres::Config::ssl_mode

host: Option<String>

This is similar to hosts but only allows one host to be specified. Unlike tokio-postgres::Config this structure differenciates between one host and more than one host. This makes it possible to store this configuration in an envorinment variable. See tokio_postgres::Config::host

hosts: Option<Vec<String>>

See tokio_postgres::Config::hosts

port: Option<u16>

This is similar to ports but only allows one port to be specified. Unlike tokio-postgres::Config this structure differenciates between one port and more than one port. This makes it possible to store this configuration in an environment variable. See tokio_postgres::Config::port

ports: Option<Vec<u16>>

See tokio_postgres::Config::port

connect_timeout: Option<Duration>

See tokio_postgres::Config::connect_timeout

keepalives: Option<bool>

See tokio_postgres::Config::keepalives

keepalives_idle: Option<Duration>

See tokio_postgres::Config::keepalives_idle

target_session_attrs: Option<TargetSessionAttrs>

See tokio_postgres::Config::target_session_attrs

channel_binding: Option<ChannelBinding>

See tokio_postgres::Config::channel_binding

manager: Option<ManagerConfig>

Manager configuration

pool: Option<PoolConfig>

Pool configuration

Implementations

impl Config[src]

pub fn new() -> Self[src]

Create new config instance with default values. This function is identical to Config::default.

pub fn from_env(prefix: &str) -> Result<Self, ConfigError>[src]

👎 Deprecated since 0.5.5:

Please embed this structure in your own config structure and use config::Config directly.

Create configuration from environment variables.

pub fn create_pool<T>(&self, tls: T) -> Result<Pool, ConfigError> where
    T: MakeTlsConnect<Socket> + Clone + Sync + Send + 'static,
    T::Stream: Sync + Send,
    T::TlsConnect: Sync + Send,
    <T::TlsConnect as TlsConnect<Socket>>::Future: Send
[src]

Create pool using the current configuration

pub fn get_pg_config(&self) -> Result<Config, ConfigError>[src]

Get tokio_postgres::Config which can be used to connect to the database.

pub fn get_manager_config(&self) -> ManagerConfig[src]

Get deadpool_postgres::ManagerConfig which can be used to construct a deadpool::managed::Pool instance.

pub fn get_pool_config(&self) -> PoolConfig[src]

Get deadpool::PoolConfig which can be used to construct a deadpool::managed::Pool instance.

Trait Implementations

impl Clone for Config[src]

impl Debug for Config[src]

impl Default for Config[src]

impl<'de> Deserialize<'de> for Config[src]

Auto Trait Implementations

impl RefUnwindSafe for Config

impl Send for Config

impl Sync for Config

impl Unpin for Config

impl UnwindSafe for Config

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[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>,