Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 15 fields pub host: String, pub port: u16, pub user: String, pub password: Option<String>, pub database: Option<String>, pub application_name: Option<String>, pub options: Option<String>, pub sslmode: SslMode, pub sslrootcert: Option<String>, pub connect_timeout: Duration, pub timezone: Option<String>, pub statement_cache_size: usize, pub max_message_len: usize, pub max_scram_iterations: u32, pub pool: PoolConfig,
}
Expand description

A parsed postgres:// connection URL.

Fields§

§host: String

Host name or IP address.

§port: u16

TCP port.

§user: String

User name.

§password: Option<String>

Password, if any.

§database: Option<String>

Database name, if any.

§application_name: Option<String>

application_name reported to the server.

§options: Option<String>

Extra options passed to the server.

§sslmode: SslMode

TLS mode.

§sslrootcert: Option<String>

Path to a PEM file of trusted root certificates.

§connect_timeout: Duration

Timeout applied to establishing a connection.

§timezone: Option<String>

IANA time zone used to interpret zone-less timestamp, date and time values. Defaults to UTC.

§statement_cache_size: usize

Maximum number of prepared statements cached per connection (0 disables caching, for transaction-mode poolers).

§max_message_len: usize

Largest accepted backend message, in bytes. Defaults to 128 MiB. A hostile server cannot make the client buffer more than this per message.

§max_scram_iterations: u32

Largest SCRAM iteration count accepted from the server. Defaults to 2,000,000. The server chooses this value and it is pure client CPU work, so it bounds the work an unauthenticated server can force.

§pool: PoolConfig

Pool settings parsed from the URL (overridden by an explicit PoolConfig).

Implementations§

Source§

impl Config

Source

pub fn parse(url: &str) -> Result<Self, Error>

Parses a postgres:// or postgresql:// URL.

Supported query parameters: sslmode, sslrootcert, connect_timeout (seconds), application_name, options, timezone, statement_cache_size, max_message_len (bytes), max_scram_iterations, pool_size, min_connections, acquire_timeout, idle_timeout and max_lifetime. Unknown parameters are rejected so that typos surface immediately.

§Errors

Returns Error::Config for a malformed URL, a missing user, or an unsupported parameter.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the configuration with the password redacted, so a config logged or printed for diagnostics cannot leak the credentials.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more