use crate::result::ArchiveResult; use std::{fs::File, path::Path}; use crate::io::{ArchiveRead, ArchiveWrite}; pub struct Archive { io: IO, } impl Archive { pub fn open(path: impl AsRef) -> ArchiveResult where IO: ArchiveRead, { Self::reader(File::open(path)?) } pub fn reader(reader: IO::Reader) -> ArchiveResult { Ok(Self { io: IO::new(reader)?, }) } } impl Archive { pub fn create(path: impl AsRef) -> ArchiveResult where IO: ArchiveWrite, { Self::writer(File::create(path)?) } pub fn writer(writer: IO::Writer) -> ArchiveResult { Ok(Self { io: IO::new(writer)?, }) } }