pub struct Config {
pub app_name: String,
pub app_env: String,
pub app_debug: bool,
pub app_url: String,
pub app_timezone: String,
pub server: ServerConfig,
pub database: DatabaseConfig,
pub logging: LoggingConfig,
pub custom: HashMap<String, Value>,
}
Expand description
Main application configuration
Fields§
§app_name: String
Application settings
app_env: String
§app_debug: bool
§app_url: String
§app_timezone: String
§server: ServerConfig
Server settings
database: DatabaseConfig
Database settings
logging: LoggingConfig
Logging settings
custom: HashMap<String, Value>
Custom settings
Implementations§
Source§impl Config
impl Config
Sourcepub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self>
Loads configuration from a TOML file
Sourcepub fn load_from_env(&mut self)
pub fn load_from_env(&mut self)
Loads configuration from environment variables
Sourcepub fn database_connection(&self, name: &str) -> Option<&DatabaseConnection>
pub fn database_connection(&self, name: &str) -> Option<&DatabaseConnection>
Gets a database connection configuration
Sourcepub fn default_database_connection(&self) -> Option<&DatabaseConnection>
pub fn default_database_connection(&self) -> Option<&DatabaseConnection>
Gets the default database connection
Sourcepub fn get<T>(&self, key: &str) -> Option<T>where
T: for<'a> Deserialize<'a>,
pub fn get<T>(&self, key: &str) -> Option<T>where
T: for<'a> Deserialize<'a>,
Gets a custom configuration value
Sourcepub fn set<T>(&mut self, key: String, value: T)where
T: Serialize,
pub fn set<T>(&mut self, key: String, value: T)where
T: Serialize,
Sets a custom configuration value
Sourcepub fn is_production(&self) -> bool
pub fn is_production(&self) -> bool
Checks if the application is in production mode
Sourcepub fn is_development(&self) -> bool
pub fn is_development(&self) -> bool
Checks if the application is in development mode
Sourcepub fn server_address(&self) -> String
pub fn server_address(&self) -> String
Gets the server bind address
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 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