Struct tusk_rs::config::DatabaseConfig
source · pub struct DatabaseConfig {
pub host: String,
pub port: i32,
pub username: String,
pub password: String,
pub database: String,
pub ssl: bool,
pub debug: bool,
}
Expand description
Defines a connection to a Postgres server.
Fields§
§host: String
§port: i32
§username: String
§password: String
§database: String
§ssl: bool
§debug: bool
Implementations§
source§impl DatabaseConfig
impl DatabaseConfig
sourcepub fn new() -> DatabaseConfig
pub fn new() -> DatabaseConfig
Creates a new database connection config. It is setup by default to connect to localhost, with the username “postgres” and a blank password.
sourcepub fn host<T: AsRef<str>>(self, host: T) -> DatabaseConfig
pub fn host<T: AsRef<str>>(self, host: T) -> DatabaseConfig
Define the host. Can be chained.
§Examples
use tusk_rs::config::DatabaseConfig;
DatabaseConfig::new().username("username").password("password")
sourcepub fn username<T: AsRef<str>>(self, username: T) -> DatabaseConfig
pub fn username<T: AsRef<str>>(self, username: T) -> DatabaseConfig
Define the username. Can be chained.
§Examples
use tusk_rs::config::DatabaseConfig;
DatabaseConfig::new().username("username").password("password")
sourcepub fn password<T: AsRef<str>>(self, password: T) -> DatabaseConfig
pub fn password<T: AsRef<str>>(self, password: T) -> DatabaseConfig
Define the password. Can be chained.
§Examples
use tusk_rs::config::DatabaseConfig;
DatabaseConfig::new().username("username").password("password")
sourcepub fn database<T: AsRef<str>>(self, database: T) -> DatabaseConfig
pub fn database<T: AsRef<str>>(self, database: T) -> DatabaseConfig
Define the database name. Can be chained.
§Examples
use tusk_rs::config::DatabaseConfig;
DatabaseConfig::new().username("username").password("password").database("database")
sourcepub fn ssl(self, ssl: bool) -> DatabaseConfig
pub fn ssl(self, ssl: bool) -> DatabaseConfig
Define whether SSL should be used. Can be chained.
§Examples
use tusk_rs::config::DatabaseConfig;
DatabaseConfig::new().username("username").password("password").ssl(true)
sourcepub fn port(self, port: i32) -> DatabaseConfig
pub fn port(self, port: i32) -> DatabaseConfig
Define the port. Can be chained.
§Examples
use tusk_rs::config::DatabaseConfig;
DatabaseConfig::new().username("username").password("password").port(5432)
sourcepub fn debug(self, debug: bool) -> DatabaseConfig
pub fn debug(self, debug: bool) -> DatabaseConfig
Define whether debug mode should be used. Can be chained.
§Examples
use tusk_rs::config::DatabaseConfig;
DatabaseConfig::new().username("username").password("password").debug(true)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnwindSafe for DatabaseConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more