mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Add new fn Crates2Json::load_from_reader
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
d9fe7bfaf4
commit
15e2213225
1 changed files with 5 additions and 1 deletions
|
@ -48,9 +48,13 @@ impl Crates2Json {
|
|||
Self::load_from_path(Self::default_path()?)
|
||||
}
|
||||
|
||||
pub fn load_from_reader<R: io::Read>(reader: R) -> Result<Self, Crates2JsonParseError> {
|
||||
Ok(serde_json::from_reader(reader)?)
|
||||
}
|
||||
|
||||
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self, Crates2JsonParseError> {
|
||||
let file = fs::File::open(path.as_ref())?;
|
||||
Ok(serde_json::from_reader(file)?)
|
||||
Self::load_from_reader(file)
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, cvs: &CrateVersionSource, info: CrateInfo) {
|
||||
|
|
Loading…
Add table
Reference in a new issue