mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 20:50:03 +00:00
Add new fn Crates2Json::write_to_writer
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
15e2213225
commit
1766b92547
1 changed files with 6 additions and 2 deletions
|
@ -65,10 +65,14 @@ impl Crates2Json {
|
|||
self.write_to_path(Self::default_path()?)
|
||||
}
|
||||
|
||||
pub fn write_to_writer<W: io::Write>(&self, writer: W) -> Result<(), Crates2JsonParseError> {
|
||||
serde_json::to_writer(writer, &self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn write_to_path(&self, path: impl AsRef<Path>) -> Result<(), Crates2JsonParseError> {
|
||||
let file = fs::File::create(path.as_ref())?;
|
||||
serde_json::to_writer(file, &self)?;
|
||||
Ok(())
|
||||
self.write_to_writer(file)
|
||||
}
|
||||
|
||||
pub fn append_to_path<Iter>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue