Struct deadpool_sqlite::Config
source · pub struct Config {
pub path: PathBuf,
pub pool: Option<PoolConfig>,
}
Expand description
Configuration object.
§Example (from environment)
By enabling the serde
feature you can read the configuration using the
config
crate as following:
SQLITE__PATH=db.sqlite3
SQLITE__POOL__MAX_SIZE=16
SQLITE__POOL__TIMEOUTS__WAIT__SECS=5
SQLITE__POOL__TIMEOUTS__WAIT__NANOS=0
#[derive(serde::Deserialize, serde::Serialize)]
struct Config {
sqlite: deadpool_sqlite::Config,
}
impl Config {
pub fn from_env() -> Result<Self, config::ConfigError> {
let mut cfg = config::Config::builder()
.add_source(config::Environment::default().separator("__"))
.build()?;
cfg.try_deserialize()
}
}
Fields§
§path: PathBuf
Path to SQLite database file.
pool: Option<PoolConfig>
Pool
configuration.
Implementations§
source§impl Config
impl Config
sourcepub fn new(path: impl Into<PathBuf>) -> Self
pub fn new(path: impl Into<PathBuf>) -> Self
Create a new Config
with the given path
of SQLite database file.
sourcepub fn create_pool(&self, runtime: Runtime) -> Result<Pool, CreatePoolError>
pub fn create_pool(&self, runtime: Runtime) -> Result<Pool, CreatePoolError>
sourcepub fn builder(&self, runtime: Runtime) -> Result<PoolBuilder, ConfigError>
pub fn builder(&self, runtime: Runtime) -> Result<PoolBuilder, ConfigError>
sourcepub fn get_pool_config(&self) -> PoolConfig
pub fn get_pool_config(&self) -> PoolConfig
Returns deadpool::managed::PoolConfig
which can be used to construct
a deadpool::managed::Pool
instance.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)