pub struct DbConfig {
pub host: String,
pub port: u16,
pub user: String,
pub password: String,
pub database: String,
pub pool_size: u32,
pub backend: Backend,
}Available on crate features
model-mysql or model-postgres or model-sqlite only.Expand description
Database connection configuration.
For SQLite, only database matters (the file path or ":memory:").
For PostgreSQL and MySQL, host, port, user, password, and database are all used.
Fields§
§host: StringHostname (ignored for SQLite).
port: u16Port (ignored for SQLite). PostgreSQL default: 5432. MySQL default: 3306.
user: StringUsername (ignored for SQLite).
password: StringPassword (ignored for SQLite).
database: StringDatabase name. For SQLite, this is the file path.
pool_size: u32Maximum number of connections in the pool.
backend: BackendWhich compiled-in backend this config connects to.
Only needs to be set explicitly when more than one model-* feature
is compiled into the binary — see Backend. When only one is
compiled in, DbConfig::from_env infers it automatically.
Implementations§
Source§impl DbConfig
impl DbConfig
Sourcepub fn from_env() -> Result<Self, DbError>
pub fn from_env() -> Result<Self, DbError>
Read configuration from environment variables.
| Variable | Default |
|---|---|
RWS_DB_BACKEND | Inferred if exactly one model-* feature is compiled in; required otherwise |
RWS_DB_HOST | localhost |
RWS_DB_PORT | 5432 |
RWS_DB_USER | (empty) |
RWS_DB_PASSWORD | (empty) |
RWS_DB_NAME | (required) |
RWS_DB_POOL_SIZE | 10 |
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DbConfig
impl RefUnwindSafe for DbConfig
impl Send for DbConfig
impl Sync for DbConfig
impl Unpin for DbConfig
impl UnsafeUnpin for DbConfig
impl UnwindSafe for DbConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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