mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Impl fn CratesToml::load_from_reader
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
9e45ba1032
commit
565b404dce
1 changed files with 6 additions and 0 deletions
|
@ -27,6 +27,12 @@ impl CratesToml {
|
||||||
Self::load_from_path(Self::default_path()?)
|
Self::load_from_path(Self::default_path()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn load_from_reader<R: io::Read>(mut reader: R) -> Result<Self, CratesTomlParseError> {
|
||||||
|
let mut vec = Vec::new();
|
||||||
|
reader.read_to_end(&mut vec)?;
|
||||||
|
Ok(toml::from_slice(&vec)?)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self, CratesTomlParseError> {
|
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self, CratesTomlParseError> {
|
||||||
let file = fs::read_to_string(path)?;
|
let file = fs::read_to_string(path)?;
|
||||||
Self::from_str(&file)
|
Self::from_str(&file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue