2 unstable releases

new 0.2.0 May 29, 2024
0.0.1 May 9, 2024

#134 in Robotics

Download history 147/week @ 2024-05-06 6/week @ 2024-05-13 10/week @ 2024-05-20

163 downloads per month
Used in 2 crates

Custom license

13KB
178 lines

⚠️ WARNING ⚠️

This crate is intended for DiMAS internal use.


lib.rs:

The configuration data.

An Agents configuration can be defined using json5 formated files. There is a set of read methods for predefined filenames available. You can find some example files here

Examples

// create a configuration from a file named `default.json5`
// located in one of the directories listed below.
// If that file does not exist, a default config will be created
let config = Config::default();

// use file named `filename.json5`
// returns an error if file does not exist or is no valid configuration file
let config = Config::from_file("filename.json5")?;

// methods with predefined filenames working like Config::from_file(...)
let config = Config::local()?;        // use file named `local.json5`
let config = Config::peer()?;         // use file named `peer.json5`
let config = Config::client()?;       // use file named `client.json5`
let config = Config::router()?;       // use file named `router.json5`

The methods using files will search in following directories for the file (order first to last):

  • current working directory
  • .config directory below current working directory
  • .config directory below home directory
  • local config directory (Linux: $XDG_CONFIG_HOME or $HOME/.config | Windows: {FOLDERID_LocalAppData} | MacOS: $HOME/Library/Application Support)
  • config directory (Linux: $XDG_CONFIG_HOME or $HOME/.config | Windows: {FOLDERID_RoamingAppData} | MacOS: $HOME/Library/Application Support)

Dependencies

~32–49MB
~833K SLoC