Struct kubos_system::Config
source · [−]pub struct Config { /* private fields */ }
Expand description
KubOS config used by either Apps or Services. KubOS config files use the TOML format, and can may contain multiple named Categories. Typically each category corresponds to an App or Service name. This allows one config file to store configuration for multiple Apps / Services at a time.
Example KubOS config files for a Service called my-service
with an IP/port binding
[my-service]
my-property = "value"
[my-service.addr]
ip = 0.0.0.0
port = 8181
Implementations
sourceimpl Config
impl Config
sourcepub fn new(name: &str) -> Result<Self, Error>
pub fn new(name: &str) -> Result<Self, Error>
Creates and parses configuration data from the system configuration file or the path passed as the ‘-c’ or ‘–config’ option to this executable.
Arguments
name
- Category name used as a key in the config file
sourcepub fn new_from_path(name: &str, path: String) -> Result<Self, Error>
pub fn new_from_path(name: &str, path: String) -> Result<Self, Error>
Creates and parses configuration data from the passed in configuration path.
Arguments
name
- Category name used as a key in the config file
path
- Path to configuration file
sourcepub fn new_from_str(name: &str, config: &str) -> Result<Self, Error>
pub fn new_from_str(name: &str, config: &str) -> Result<Self, Error>
Creates and parses configuration data from the passed in configuration string.
Arguments
name
- Category name used as a key in the config
config
- Config data as a string
sourcepub fn hosturl(&self) -> Option<String>
pub fn hosturl(&self) -> Option<String>
Returns the configured hosturl string in the following format (using IPv4 addresses) - 0.0.0.0:0000
sourcepub fn raw(&self) -> Value
pub fn raw(&self) -> Value
Returns the category’s configuration information
in the toml::Value
format.
This will contain the ip/port if provided, along with any other
configuration information found in the config file.
Examples
use kubos_system::Config;
let config = Config::new("example-service").unwrap();
let raw = config.raw();
let bus = raw["bus"].as_str();
Trait Implementations
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