Struct PostgresConnectionString

Source
pub struct PostgresConnectionString { /* private fields */ }
Expand description

Struct representing a PostgreSQL connection string

Implementations§

Source§

impl PostgresConnectionString

Source

pub fn new() -> Self

Creates a new and empty PostgresConnectionString

This function initializes a new PostgresConnectionString with empty values. Without any further changes this results in the string postgres:// which isn’t really useful.

This function can be chained other functions to fill the missing fields in the connection string.

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new()
  .set_username_and_password("user", "password")
  .set_host_with_port("localhost", 5432)
  .set_database_name("db_name")
  .set_connect_timeout(30);
Source

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

Sets/Replaces the username and omits the password in the connection string

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new().set_username_without_password("user");
Source

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

Sets/Replaces the username and the password

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new().set_username_and_password("user", "password");
Source

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

Sets/Replaces the host and omits the port in the connection string (this usually results in the usage of the default port)

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new().set_host_with_default_port("localhost");
Source

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

Sets/Replaces the host and the port

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new().set_host_with_port("localhost", 5432);
Source

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

Sets/Replaces the database name

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new().set_database_name("db_name");
Source

pub fn set_connect_timeout(self, timeout: usize) -> Self

Sets/Replaces the connect timeout in seconds

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new().set_connect_timeout(30);
Source

pub fn dangerously_set_parameter(self, key: &str, value: &str) -> Self

Sets/replaces ANY parameter even if it doesn’t exist in the list of allowed/implemented parameters

§Examples
use connection_string_generator::postgres::PostgresConnectionString;

PostgresConnectionString::new().dangerously_set_parameter("parameter", "value");

Trait Implementations§

Source§

impl Debug for PostgresConnectionString

Source§

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

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

impl Default for PostgresConnectionString

Source§

fn default() -> Self

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

impl Display for PostgresConnectionString

Source§

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

Formats the value using the given formatter. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.