cargo_wiki/wiki/mod.rs
1pub mod generator;
2
3use anyhow::Result;
4use rustdoc_types::Crate;
5use std::fs;
6use std::path::Path;
7
8pub trait CrateExt {
9 fn from_file<P: AsRef<Path>>(file: P) -> Result<Crate>;
10}
11
12impl CrateExt for Crate {
13 fn from_file<P: AsRef<Path>>(file: P) -> Result<Crate> {
14 let bytes = fs::read(file)?;
15 Ok(serde_json::from_slice(&bytes)?)
16 }
17}