optify 1.3.0

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. This library is mainly made to support building implementations for other languages such as Node.js, Python, and Ruby. It is not meant to be consumed directly yet.
Documentation
use std::{fs::File, io::BufReader, path::Path};

use serde::de::DeserializeOwned;

pub(crate) fn read_json_from_file(
    path: impl AsRef<Path>,
) -> Result<serde_json::Value, Box<dyn std::error::Error>> {
    read_json_from_file_as(path)
}

pub(crate) fn read_json_from_file_as<T>(
    path: impl AsRef<Path>,
) -> Result<T, Box<dyn std::error::Error>>
where
    T: DeserializeOwned,
{
    let file = File::open(path)?;
    let reader = BufReader::new(file);
    let result = serde_json::from_reader(reader)?;
    Ok(result)
}