diff options
Diffstat (limited to 'src/archive.rs')
| -rw-r--r-- | src/archive.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/archive.rs b/src/archive.rs index e635007..4a70867 100644 --- a/src/archive.rs +++ b/src/archive.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use crate::driver::{ArchiveRead, ArchiveWrite, Driver}; | 1 | use crate::driver::{ArchiveRead, ArchiveWrite, Driver}; |
| 2 | use crate::ArchiveResult; | 2 | use crate::{ArchiveFile, ArchiveResult}; |
| 3 | use std::fs::File; | 3 | use std::fs::File; |
| 4 | use std::io::{Read, Write}; | 4 | use std::io::{Read, Write}; |
| 5 | use std::path::Path; | 5 | use std::path::Path; |
| @@ -10,9 +10,9 @@ pub struct Archive<D: Driver> { | |||
| 10 | 10 | ||
| 11 | impl<D: ArchiveRead> Archive<D> | 11 | impl<D: ArchiveRead> Archive<D> |
| 12 | where | 12 | where |
| 13 | D::IO: std::io::Read, | 13 | D::Io: std::io::Read, |
| 14 | { | 14 | { |
| 15 | pub fn read(io: D::IO) -> ArchiveResult<Self, D::Error> { | 15 | pub fn read(io: D::Io) -> ArchiveResult<Self, D::Error> { |
| 16 | Ok(Self { | 16 | Ok(Self { |
| 17 | driver: D::read(io)?, | 17 | driver: D::read(io)?, |
| 18 | }) | 18 | }) |
| @@ -20,18 +20,22 @@ where | |||
| 20 | 20 | ||
| 21 | pub fn read_from_file(path: impl AsRef<Path>) -> ArchiveResult<Self, D::Error> | 21 | pub fn read_from_file(path: impl AsRef<Path>) -> ArchiveResult<Self, D::Error> |
| 22 | where | 22 | where |
| 23 | D: ArchiveRead<IO = File>, | 23 | D: ArchiveRead<Io = File>, |
| 24 | { | 24 | { |
| 25 | Self::read(File::open(path)?) | 25 | Self::read(File::open(path)?) |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | pub fn files(&self) -> Vec<&D::File> { | 28 | pub fn files(&self) -> Vec<&D::FileInfo> { |
| 29 | self.driver.files() | 29 | self.driver.files() |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | pub fn get_file(&self, name: &str) -> Option<&D::File> { | 32 | pub fn get_file_info(&self, name: &str) -> Option<&D::FileInfo> { |
| 33 | self.driver.get_file(name) | 33 | self.driver.get_file_info(name) |
| 34 | } | ||
| 35 | |||
| 36 | pub fn get_file_reader<'d>(&'d mut self, name: &str) -> Option<ArchiveFile<D::FileDriver<'d>>> { | ||
| 37 | Some(ArchiveFile::new(self.driver.get_file_reader(name)?)) | ||
| 34 | } | 38 | } |
| 35 | } | 39 | } |
| 36 | 40 | ||
| 37 | impl<D: ArchiveWrite> Archive<D> where D::IO: Read + Write {} | 41 | impl<D: ArchiveWrite> Archive<D> where D::Io: Read + Write {} |
