chore: allow internal use of deprecated items
This commit is contained in:
parent
548db12b07
commit
e8f576e179
3 changed files with 15 additions and 1 deletions
|
@ -34,6 +34,7 @@ impl CompressionMethod {
|
|||
8 => CompressionMethod::Deflated,
|
||||
#[cfg(feature = "bzip2")]
|
||||
12 => CompressionMethod::Bzip2,
|
||||
#[allow(deprecated)]
|
||||
v => CompressionMethod::Unsupported(v),
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +51,7 @@ impl CompressionMethod {
|
|||
CompressionMethod::Deflated => 8,
|
||||
#[cfg(feature = "bzip2")]
|
||||
CompressionMethod::Bzip2 => 12,
|
||||
#[allow(deprecated)]
|
||||
CompressionMethod::Unsupported(v) => v,
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +71,9 @@ mod test {
|
|||
#[test]
|
||||
fn from_eq_to() {
|
||||
for v in 0..(::std::u16::MAX as u32 + 1) {
|
||||
#[allow(deprecated)]
|
||||
let from = CompressionMethod::from_u16(v as u16);
|
||||
#[allow(deprecated)]
|
||||
let to = from.to_u16() as u32;
|
||||
assert_eq!(v, to);
|
||||
}
|
||||
|
@ -88,8 +92,11 @@ mod test {
|
|||
#[test]
|
||||
fn to_eq_from() {
|
||||
fn check_match(method: CompressionMethod) {
|
||||
#[allow(deprecated)]
|
||||
let to = method.to_u16();
|
||||
#[allow(deprecated)]
|
||||
let from = CompressionMethod::from_u16(to);
|
||||
#[allow(deprecated)]
|
||||
let back = from.to_u16();
|
||||
assert_eq!(to, back);
|
||||
}
|
||||
|
|
|
@ -362,7 +362,10 @@ fn central_header_to_zip_file<R: Read + io::Seek>(
|
|||
system: System::from_u8((version_made_by >> 8) as u8),
|
||||
version_made_by: version_made_by as u8,
|
||||
encrypted,
|
||||
compression_method: CompressionMethod::from_u16(compression_method),
|
||||
compression_method: {
|
||||
#[allow(deprecated)]
|
||||
CompressionMethod::from_u16(compression_method)
|
||||
},
|
||||
last_modified_time: DateTime::from_msdos(last_mod_date, last_mod_time),
|
||||
crc32,
|
||||
compressed_size: compressed_size as u64,
|
||||
|
@ -615,6 +618,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>(
|
|||
let encrypted = flags & 1 == 1;
|
||||
let is_utf8 = flags & (1 << 11) != 0;
|
||||
let using_data_descriptor = flags & (1 << 3) != 0;
|
||||
#[allow(deprecated)]
|
||||
let compression_method = CompressionMethod::from_u16(reader.read_u16::<LittleEndian>()?);
|
||||
let last_mod_time = reader.read_u16::<LittleEndian>()?;
|
||||
let last_mod_date = reader.read_u16::<LittleEndian>()?;
|
||||
|
|
|
@ -408,6 +408,7 @@ impl<W: Write + io::Seek> GenericZipWriter<W> {
|
|||
CompressionMethod::Bzip2 => {
|
||||
GenericZipWriter::Bzip2(BzEncoder::new(bare, bzip2::Compression::Default))
|
||||
}
|
||||
#[allow(deprecated)]
|
||||
CompressionMethod::Unsupported(..) => {
|
||||
return Err(ZipError::UnsupportedArchive("Unsupported compression"))
|
||||
}
|
||||
|
@ -473,6 +474,7 @@ fn write_local_file_header<T: Write>(writer: &mut T, file: &ZipFileData) -> ZipR
|
|||
};
|
||||
writer.write_u16::<LittleEndian>(flag)?;
|
||||
// Compression method
|
||||
#[allow(deprecated)]
|
||||
writer.write_u16::<LittleEndian>(file.compression_method.to_u16())?;
|
||||
// last mod file time and last mod file date
|
||||
writer.write_u16::<LittleEndian>(file.last_modified_time.timepart())?;
|
||||
|
@ -524,6 +526,7 @@ fn write_central_directory_header<T: Write>(writer: &mut T, file: &ZipFileData)
|
|||
};
|
||||
writer.write_u16::<LittleEndian>(flag)?;
|
||||
// compression method
|
||||
#[allow(deprecated)]
|
||||
writer.write_u16::<LittleEndian>(file.compression_method.to_u16())?;
|
||||
// last mod file time + date
|
||||
writer.write_u16::<LittleEndian>(file.last_modified_time.timepart())?;
|
||||
|
|
Loading…
Add table
Reference in a new issue