pub struct Configuration {
pub settings: RwLock<TorrustBackend>,
pub config_path: Option<String>,
}
Expand description
The configuration service.
Fields§
§settings: RwLock<TorrustBackend>
The state of the configuration.
config_path: Option<String>
The path to the configuration file. This is None
if the configuration
was loaded from the environment.
Implementations§
Source§impl Configuration
impl Configuration
Sourcepub async fn load_from_file(
config_path: &str,
) -> Result<Configuration, ConfigError>
pub async fn load_from_file( config_path: &str, ) -> Result<Configuration, ConfigError>
Loads the configuration from the configuration file.
§Errors
This function will return an error no configuration in the CONFIG_PATH
exists, and a new file is is created.
This function will return an error if the config
is not a valid TorrustConfig
document.
Sourcepub fn load_from_env_var(
config_env_var_name: &str,
) -> Result<Configuration, ConfigError>
pub fn load_from_env_var( config_env_var_name: &str, ) -> Result<Configuration, ConfigError>
Loads the configuration from the environment variable. The whole configuration must be in the environment variable. It contains the same configuration as the configuration file with the same format.
§Errors
Will return Err
if the environment variable does not exist or has a bad configuration.
Sourcepub async fn save_to_file(&self, config_path: &str)
pub async fn save_to_file(&self, config_path: &str)
Returns the save to file of this Configuration
.
§Panics
This function will panic if it can’t write to the file.
pub async fn get_all(&self) -> TorrustBackend
pub async fn get_public(&self) -> ConfigurationPublic
pub async fn get_site_name(&self) -> String
pub async fn get_api_base_url(&self) -> Option<String>
Trait Implementations§
Source§impl Debug for Configuration
impl Debug for Configuration
Source§impl Default for Configuration
impl Default for Configuration
Source§fn default() -> Configuration
fn default() -> Configuration
Auto Trait Implementations§
impl !Freeze for Configuration
impl !RefUnwindSafe for Configuration
impl Send for Configuration
impl Sync for Configuration
impl Unpin for Configuration
impl !UnwindSafe for Configuration
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
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>
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>
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