pathbuf for input

This commit is contained in:
Andrea Fioraldi 2020-10-31 12:43:03 +01:00
parent 069c559804
commit a64d2f7b01

View File

@ -4,17 +4,18 @@ pub use bytes::BytesInput;
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
use std::io::Write; use std::io::Write;
use std::path::PathBuf;
use crate::AflError; use crate::AflError;
pub trait Input { pub trait Input {
fn to_file(&self, path: &str) -> Result<(), AflError> { fn to_file(&self, path: &PathBuf) -> Result<(), AflError> {
let mut file = File::create(path)?; let mut file = File::create(path)?;
file.write_all(self.serialize()?)?; file.write_all(self.serialize()?)?;
Ok(()) Ok(())
} }
fn from_file(&mut self, path: &str) -> Result<(), AflError> { fn from_file(&mut self, path: &PathBuf) -> Result<(), AflError> {
let mut file = File::create(path)?; let mut file = File::create(path)?;
let mut buf = vec![]; let mut buf = vec![];
file.read_to_end(&mut buf)?; file.read_to_end(&mut buf)?;