pub struct Config { /* private fields */ }Expand description
Relay’s Configuration.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Config>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Config>
Loads a config from a given config folder.
Sourcepub fn from_json_value(value: Value) -> Result<Config>
pub fn from_json_value(value: Value) -> Result<Config>
Creates a config from a JSON value.
This is mostly useful for tests.
Sourcepub fn apply_override(
&mut self,
overrides: OverridableConfig,
) -> Result<&mut Self>
pub fn apply_override( &mut self, overrides: OverridableConfig, ) -> Result<&mut Self>
Override configuration with values coming from other sources (e.g. env variables or command line parameters).
If applying the overrides fails, the config may be left in an inconsistent state.
Sourcepub fn config_exists<P: AsRef<Path>>(path: P) -> bool
pub fn config_exists<P: AsRef<Path>>(path: P) -> bool
Checks if the config is already initialized.
Sourcepub fn to_yaml_string(&self) -> Result<String>
pub fn to_yaml_string(&self) -> Result<String>
Dumps out a YAML string of the values.
Sourcepub fn replace_credentials(
&mut self,
credentials: Option<Credentials>,
) -> Result<bool>
pub fn replace_credentials( &mut self, credentials: Option<Credentials>, ) -> Result<bool>
Set new credentials.
This also writes the credentials back to the file, if this config was loaded from the file-system.
Sourcepub fn reload(&self) -> Result<bool>
pub fn reload(&self) -> Result<bool>
Reloads the configuration from disk.
Returns true if the configuration changed.
In order for a config to be reloadable it must’ve been loaded from a path. The original config will be re-read and reloadable parts of the config will be replaced with their updated values.
If the reload fails for any reason, the current config is untouched.
Sourcepub fn current(&self) -> ConfigSnapshot
pub fn current(&self) -> ConfigSnapshot
Acquires a current snapshot of the config.
A snapshot is the way to actually consume values from the config. A snapshot should ideally be acquired once per unit of work.
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 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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