pub struct Config {
pub path: PathBuf,
pub durability: DurabilityLevel,
pub drop_if_exists: bool,
pub pool: Option<PoolConfig>,
}Expand description
Configuration object for deadpool-apexbase.
§Example (from environment)
By enabling the serde feature you can read the configuration using the
config crate as following:
APEXBASE__PATH=/tmp/apex_db
APEXBASE__POOL__MAX_SIZE=16
APEXBASE__POOL__TIMEOUTS__WAIT__SECS=5
APEXBASE__POOL__TIMEOUTS__WAIT__NANOS=0ⓘ
#[derive(serde::Deserialize, serde::Serialize)]
struct Config {
apexbase: deadpool_apexbase::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: PathBufPath to the ApexBase database directory.
durability: DurabilityLevelDurability level for the database.
Default: DurabilityLevel::Safe
drop_if_exists: boolWhether to drop existing .apex files when opening.
Default: false
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 the database directory.
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§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin 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§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