mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-21 13:08:42 +00:00
Impl new fn CratesToml::write_to_writer
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
565b404dce
commit
7311f77f29
1 changed files with 9 additions and 0 deletions
|
@ -46,6 +46,15 @@ impl CratesToml {
|
|||
self.write_to_path(Self::default_path()?)
|
||||
}
|
||||
|
||||
pub fn write_to_writer<W: io::Write>(
|
||||
&self,
|
||||
mut writer: W,
|
||||
) -> Result<u64, CratesTomlParseError> {
|
||||
let data = toml::to_vec(&self)?;
|
||||
writer.write_all(&data)?;
|
||||
Ok(data.len().try_into().unwrap())
|
||||
}
|
||||
|
||||
pub fn write_to_path(&self, path: impl AsRef<Path>) -> Result<(), CratesTomlParseError> {
|
||||
fs::write(path, &toml::to_vec(&self)?)?;
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Reference in a new issue