Function read_config

Source
pub fn read_config(archive_root: &str) -> Vec<System>
Expand description

Returns a collection of System instances based on the archive’s configuration file.

§Valid file system structure example

Follow these guidelines to reduce unexpected behavior when using this crate.

Side note: A “system directory” is a directory that contains games for a single system.

Your archive’s file structure is valid if:

  • The configuration file is located in the archive root
  • System directories are never nested
  • For any system directory, games are represented as either normal files or directories (never both)
/game/archive/root
├── ds
│   ├── game-1.nds
│   ├── game-2.nds
│   └── game-3.nds
├── wii
│   ├── game-1-dir
│   │   └── game-1.wbfs
│   └── game-2-dir
│       └── game-2.wbfs
└── config.yaml

§Valid configuration file example

# config.yaml in archive root
systems:
  ds: # system "label" — call it whatever you want!
    display_name: "DS"
    color: [135,215,255]
    path: "ds" # path to system dir relative to archive root
    games_are_directories: false # are games stored as directories?
  snes:
    display_name: "SNES"
    color: [95,0,255]
    path: "snes"
    games_are_directories: false
  wii:
    display_name: "WII"
    color: [0,215,255]
    path: "wbfs"
    games_are_directories: true

§Panics

Will panic if any of the following are true:

  • The provided archive_root path does not exist.
  • The configuration file
    • Cannot be found.
    • Does not contain the expected fields.
    • Contains a system with a nonexistent path.