Struct PostgresConfigBuilder

Source
pub struct PostgresConfigBuilder {
Show 14 fields pub host: String, pub port: u16, pub user: String, pub password: Option<String>, pub database: String, pub application_name: Option<String>, pub connect_timeout: Option<u64>, pub ssl_mode: Option<String>, pub pool_max_size: Option<u32>, pub pool_min_idle: Option<u32>, pub pool_idle_timeout: Option<Duration>, pub pool_connection_timeout: Option<Duration>, pub pool_max_lifetime: Option<Duration>, pub use_pool: bool,
}
Expand description

PostgreSQL connection configuration builder

This struct is used to build a PostgreSQL connection configuration. It follows the builder pattern to allow for flexible configuration.

Fields§

§host: String§port: u16§user: String§password: Option<String>§database: String§application_name: Option<String>§connect_timeout: Option<u64>§ssl_mode: Option<String>§pool_max_size: Option<u32>§pool_min_idle: Option<u32>§pool_idle_timeout: Option<Duration>§pool_connection_timeout: Option<Duration>§pool_max_lifetime: Option<Duration>§use_pool: bool

Implementations§

Source§

impl PostgresConfigBuilder

Source

pub fn new() -> Self

Create a new PostgreSQL connection configuration builder with default values

Source

pub fn host(self, host: &str) -> Self

Set the host for the PostgreSQL connection

Source

pub fn port(self, port: u16) -> Self

Set the port for the PostgreSQL connection

Source

pub fn user(self, user: &str) -> Self

Set the user for the PostgreSQL connection

Source

pub fn password(self, password: &str) -> Self

Set the password for the PostgreSQL connection

Source

pub fn database(self, database: &str) -> Self

Set the database for the PostgreSQL connection

Source

pub fn application_name(self, application_name: &str) -> Self

Set the application name for the PostgreSQL connection

Source

pub fn connect_timeout(self, seconds: u64) -> Self

Set the connection timeout in seconds

Source

pub fn ssl_mode(self, ssl_mode: &str) -> Self

Set the SSL mode for the PostgreSQL connection

Source

pub fn use_pool(self, use_pool: bool) -> Self

Enable connection pooling

Source

pub fn pool_max_size(self, size: u32) -> Self

Set the maximum size of the connection pool

Source

pub fn pool_min_idle(self, size: u32) -> Self

Set the minimum number of idle connections in the pool

Source

pub fn pool_idle_timeout(self, timeout: Duration) -> Self

Set the idle timeout for connections in the pool

Source

pub fn pool_connection_timeout(self, timeout: Duration) -> Self

Set the connection timeout for the pool

Source

pub fn pool_max_lifetime(self, lifetime: Duration) -> Self

Set the maximum lifetime of connections in the pool

Source

pub fn build_connection_string(&self) -> String

Build the connection string from the configuration

Source

pub fn build(&self) -> Result<Client, PostgresError>

Build a PostgreSQL client from the configuration

Source

pub fn build_pool( &self, ) -> Result<Pool<PostgresConnectionManager<NoTls>>, Error>

Build a PostgreSQL connection pool from the configuration

Trait Implementations§

Source§

impl Debug for PostgresConfigBuilder

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PostgresConfigBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

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

Source§

fn vzip(self) -> V