mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 13:38:43 +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()?)
|
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> {
|
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self, Crates2JsonParseError> {
|
||||||
let file = fs::File::open(path.as_ref())?;
|
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) {
|
pub fn insert(&mut self, cvs: &CrateVersionSource, info: CrateInfo) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue