# Optify in Rust

[![Crates.io](https://img.shields.io/crates/v/optify)](https://crates.io/crates/optify)
[![docs.rs](https://img.shields.io/docsrs/optify)](https://docs.rs/optify)

The core implementation of Optify in Rust.
Simplifies getting the right configuration options for a process using pre-loaded configurations from files (JSON, YAML, etc.) to manage options for experiments or flights.

See [tests](../../tests/) for examples and tests for different implementations of this format for managing options.

See the root [README.md](../../README.md) for more information and examples.

## How It Works

The [`config`][config] crate (library) is used to help load configuration files.
This allows us to load many different types of files, including JSON, JSON5, YAML, and more.
We no longer use the `config` crate to combine configuration files because it was slower to merge them and deserialize the result than our custom merging logic since we know that we want to use `serde_json::Value`s.

We merge configurations starting with the first one given and thus the final feature overrides the previous ones.
We may try to optimize further in the future, but this is fine now when there are just a few features or imports and when keys are mostly unique.

Optionally, when working locally, there is support to watch for changes to the configuration files and folders using the [`notify-debouncer-full`][notify-debouncer-full] crate (library).

## Testing

Run:
```shell
cargo test
```

## Formatting
To automatically change code, run:
```shell
cargo fmt && cargo clippy --fix --allow-dirty --allow-staged
```

## Benchmarking
Run:
```shell
cargo build --release
cargo bench

# Run one specific benchmark, example:
cargo bench --bench get_options_benchmark

# Open one of the reports
open target/criterion/*/report/index.html
```

## Publishing
```shell
cargo login
cargo publish
```

[config]: https://crates.io/crates/config
[notify-debouncer-full]: https://crates.io/crates/notify-debouncer-full
