pub struct Config {
inner: RwLock<ConfigInner>,
file: Option<PathBuf>,
}
Expand description
Global configuration for the links redirector server. This is the more
idiomatic, easier to use (in rust code), and shareable-across-threads
version, which can be updated from a Partial
.
Fields§
§inner: RwLock<ConfigInner>
§file: Option<PathBuf>
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(file: Option<PathBuf>) -> Self
pub fn new(file: Option<PathBuf>) -> Self
Create a new Config
instance using the provided file path as the
configuration file. Configuration data is parsed from environment
variables, the config file, and command-line arguments, in that order.
If there is an error with the configuration file or any other
configuration source, no error is emitted. Instead, a warning is logged,
and the other configuration sources are used.
§IO
This function performs synchronous file IO, and should therefore not be used inside of an asynchronous context.
Sourcepub fn new_static(file: Option<PathBuf>) -> &'static Self
pub fn new_static(file: Option<PathBuf>) -> &'static Self
Create a new static reference to a new Config
instance using the
provided file path as the configuration file. Configuration data is
parsed from environment variables, the config file, and command-line
arguments, in that order. If there is an error with the configuration
file or any other configuration source, no error is emitted. Instead, a
warning is logged, and the other configuration sources are used.
§Memory
Because this function leaks memory with no (safe) way of freeing it, care should be taken not to call this function an unbounded number of times.
§IO
This function performs synchronous file IO, and should therefore not be used inside of an asynchronous context.
Sourcepub fn update(&self)
pub fn update(&self)
Update this config from environment variables, config file, and
command-line arguments. This function starts with defaults for each
option, then updates those from environment variables, then from the
config file, then from command-line arguments, and finally overwrites
this Config
’s options with those newly-parsed ones.
§IO
This function performs synchronous file IO, and should therefore not be used inside of an asynchronous context.
Sourcepub fn redirector(&self) -> Redirector
pub fn redirector(&self) -> Redirector
Generate a redirector configuration from the options defined in this global links config.
Sourcepub fn listeners(&self) -> Vec<ListenAddress>
pub fn listeners(&self) -> Vec<ListenAddress>
Get the list of listener addresses
Sourcepub fn statistics(&self) -> StatisticCategories
pub fn statistics(&self) -> StatisticCategories
Get the types of statistics to collect
Sourcepub fn default_certificate(&self) -> DefaultCertificateSource
pub fn default_certificate(&self) -> DefaultCertificateSource
Get the default TLS certificate source
Sourcepub fn certificates(&self) -> Vec<CertificateSource>
pub fn certificates(&self) -> Vec<CertificateSource>
Get the TLS certificate configuration
Sourcepub fn https_redirect(&self) -> bool
pub fn https_redirect(&self) -> bool
Get the https_redirect
configuration option
Sourcepub fn send_alt_svc(&self) -> bool
pub fn send_alt_svc(&self) -> bool
Get the send_alt_svc
configuration option
Sourcepub fn send_server(&self) -> bool
pub fn send_server(&self) -> bool
Get the send_server
configuration option
Sourcepub fn store(&self) -> BackendType
pub fn store(&self) -> BackendType
Get the store type
Sourcepub fn store_config(&self) -> HashMap<String, String>
pub fn store_config(&self) -> HashMap<String, String>
Get the store backend configuration
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
§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> 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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request