diff options
Diffstat (limited to 'src/zip/file.rs')
| -rw-r--r-- | src/zip/file.rs | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/src/zip/file.rs b/src/zip/file.rs deleted file mode 100644 index 261390f..0000000 --- a/src/zip/file.rs +++ /dev/null | |||
| @@ -1,124 +0,0 @@ | |||
| 1 | use crate::file::{ArchiveFile, ArchiveFileRead, ArchiveFileWrite}; | ||
| 2 | use crate::result::{ArchiveError, ArchiveResult}; | ||
| 3 | use chrono::NaiveDateTime; | ||
| 4 | use std::io::{Read, Write}; | ||
| 5 | |||
| 6 | pub struct GeneralPurposeBitFlag {} | ||
| 7 | |||
| 8 | pub enum CompressionMethod { | ||
| 9 | Store, | ||
| 10 | Deflate, | ||
| 11 | Bzip2, | ||
| 12 | LZMA, | ||
| 13 | Zstandard, | ||
| 14 | } | ||
| 15 | |||
| 16 | impl TryFrom<u16> for CompressionMethod { | ||
| 17 | type Error = ArchiveError; | ||
| 18 | |||
| 19 | fn try_from(value: u16) -> ArchiveResult<Self> { | ||
| 20 | Ok(match value { | ||
| 21 | 0 => Self::Store, | ||
| 22 | 8 => Self::Deflate, | ||
| 23 | 12 => Self::Bzip2, | ||
| 24 | 14 => Self::LZMA, | ||
| 25 | 93 | 20 => Self::Zstandard, | ||
| 26 | _ => return Err(ArchiveError::UnsupportedCompressionMethod { method: value }), | ||
| 27 | }) | ||
| 28 | } | ||
| 29 | } | ||
| 30 | |||
| 31 | pub struct FileInfo { | ||
| 32 | number: u64, | ||
| 33 | version_made_by: u16, | ||
| 34 | version_needed: u16, | ||
| 35 | general_purpose_bit_flag: GeneralPurposeBitFlag, | ||
| 36 | compression_method: CompressionMethod, | ||
| 37 | file_modified_at: NaiveDateTime, | ||
| 38 | crc32: u32, | ||
| 39 | compressed_size: u64, | ||
| 40 | uncompressed_size: u64, | ||
| 41 | name: String, | ||
| 42 | comment: String, | ||
| 43 | header_offset: u64, | ||
| 44 | } | ||
| 45 | |||
| 46 | impl FileInfo { | ||
| 47 | pub fn new( | ||
| 48 | number: u64, | ||
| 49 | version_made_by: u16, | ||
| 50 | version_needed: u16, | ||
| 51 | general_purpose_bit_flag: GeneralPurposeBitFlag, | ||
| 52 | compression_method: CompressionMethod, | ||
| 53 | file_modified_at: NaiveDateTime, | ||
| 54 | crc32: u32, | ||
| 55 | compressed_size: u64, | ||
| 56 | uncompressed_size: u64, | ||
| 57 | name: String, | ||
| 58 | comment: String, | ||
| 59 | header_offset: u64, | ||
| 60 | ) -> Self { | ||
| 61 | Self { | ||
| 62 | number, | ||
| 63 | version_made_by, | ||
| 64 | version_needed, | ||
| 65 | general_purpose_bit_flag, | ||
| 66 | compression_method, | ||
| 67 | file_modified_at, | ||
| 68 | crc32, | ||
| 69 | compressed_size, | ||
| 70 | uncompressed_size, | ||
| 71 | name, | ||
| 72 | comment, | ||
| 73 | header_offset, | ||
| 74 | } | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | pub struct FileReader { | ||
| 79 | info: FileInfo, | ||
| 80 | } | ||
| 81 | |||
| 82 | impl ArchiveFile for FileReader { | ||
| 83 | type Info = FileInfo; | ||
| 84 | |||
| 85 | fn new(info: Self::Info) -> Self { | ||
| 86 | Self { info } | ||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | impl Read for FileReader { | ||
| 91 | fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { | ||
| 92 | todo!() | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | impl ArchiveFileRead for FileReader {} | ||
| 97 | |||
| 98 | impl FileReader {} | ||
| 99 | |||
| 100 | pub struct FileWriter { | ||
| 101 | info: FileInfo, | ||
| 102 | } | ||
| 103 | |||
| 104 | impl ArchiveFile for FileWriter { | ||
| 105 | type Info = FileInfo; | ||
| 106 | |||
| 107 | fn new(info: Self::Info) -> Self { | ||
| 108 | Self { info } | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | impl Write for FileWriter { | ||
| 113 | fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | ||
| 114 | todo!() | ||
| 115 | } | ||
| 116 | |||
| 117 | fn flush(&mut self) -> std::io::Result<()> { | ||
| 118 | todo!() | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | impl ArchiveFileWrite for FileWriter {} | ||
| 123 | |||
| 124 | impl FileWriter {} | ||
