trustformers-core 0.1.1

Core traits and utilities for TrustformeRS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::errors::Result;
use crate::traits::Config;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;

pub fn load_config<T: Config>(path: &Path) -> Result<T> {
    let file = File::open(path)?;
    let reader = BufReader::new(file);
    let config: T = serde_json::from_reader(reader)?;
    config.validate()?;
    Ok(config)
}