use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
use crate::error::{Med64Error, Result};
pub(crate) fn create_writer(path: &Path) -> Result<BufWriter<File>> {
let file = File::create(path)
.map_err(|source| Med64Error::WriteIo { path: path.to_path_buf(), source })?;
Ok(BufWriter::new(file))
}
pub(crate) fn io(path: &Path) -> impl Fn(std::io::Error) -> Med64Error + '_ {
|source| Med64Error::WriteIo { path: path.to_path_buf(), source }
}