pub struct DatabaseConfig {
pub url: String,
pub max_connections: u32,
pub min_connections: u32,
pub connect_timeout: u64,
pub logging: bool,
}Expand description
Database configuration
§Environment Variables
DATABASE_URL- Full connection URL (required for connection, defaults to sqlite://./database.db)DB_MAX_CONNECTIONS- Maximum pool connections (default: 10)DB_MIN_CONNECTIONS- Minimum pool connections (default: 1)DB_CONNECT_TIMEOUT- Connection timeout in seconds (default: 30)DB_LOGGING- Enable SQL logging (default: false)
§Example
ⓘ
use ferro_rs::{Config, DatabaseConfig};
// Register from environment
Config::register(DatabaseConfig::from_env());
// Or build manually
Config::register(DatabaseConfig::builder()
.url("postgres://localhost/mydb")
.max_connections(20)
.build());Fields§
§url: StringFull database connection URL
max_connections: u32Maximum connections in pool
min_connections: u32Minimum connections in pool
connect_timeout: u64Connection timeout in seconds
logging: boolEnable SQL query logging
Implementations§
Source§impl DatabaseConfig
impl DatabaseConfig
Sourcepub fn builder() -> DatabaseConfigBuilder
pub fn builder() -> DatabaseConfigBuilder
Create a builder for manual configuration
Sourcepub fn database_type(&self) -> DatabaseType
pub fn database_type(&self) -> DatabaseType
Detect database type from URL
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
Check if database URL is configured (not the default)
Trait Implementations§
Source§impl Clone for DatabaseConfig
impl Clone for DatabaseConfig
Source§fn clone(&self) -> DatabaseConfig
fn clone(&self) -> DatabaseConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DatabaseConfig
impl Debug for DatabaseConfig
Auto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more