pub struct Config {
pub units: UnitSet,
pub targets: TargetSet,
pub log: LogConfig,
pub http: Server,
}
Expand description
The complete RTRTR configuration.
All configuration is available via public fields.
The associated function init
should be called first thing
as it initializes the operational environment such as logging. Thereafter,
config_args
can be used to configure a clap app to
be able to pick up the path to the configuration file.
from_arg_matches
will then load the file
referenced in the command line and, upon success, return the config.
Fields
units: UnitSet
The set of configured units.
targets: TargetSet
The set of configured targets.
log: LogConfig
The logging configuration.
http: Server
The HTTP server configuration.
Implementations
sourceimpl Config
impl Config
sourcepub fn init() -> Result<(), ExitError>
pub fn init() -> Result<(), ExitError>
Initialises everything.
This function should be called first thing.
sourcepub fn from_toml(
slice: &[u8],
base_dir: Option<impl AsRef<Path>>
) -> Result<Self, Error>
pub fn from_toml(
slice: &[u8],
base_dir: Option<impl AsRef<Path>>
) -> Result<Self, Error>
Creates a configuration from a bytes slice with TOML data.
sourcepub fn config_args(app: Command<'_>) -> Command<'_>
pub fn config_args(app: Command<'_>) -> Command<'_>
Configures a clap app with the arguments to load the configuration.
sourcepub fn from_arg_matches(
matches: &ArgMatches,
cur_dir: &Path,
manager: &mut Manager
) -> Result<Self, Failed>
pub fn from_arg_matches(
matches: &ArgMatches,
cur_dir: &Path,
manager: &mut Manager
) -> Result<Self, Failed>
Loads the configuration based on command line options provided.
The matches
must be the result of getting argument matches from a
clap app previously configured with
config_args
. Otherwise, the function is likely
to panic.
The current path needs to be provided to be able to deal with relative paths. The manager is necessary to resolve links given in the configuration.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
sourcefn 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 !RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more