Debian Codegraph @

src/tests/write/zip64/mod.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 // Copyright Cognite AS, 2023
2
3 use craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::writerust-analyzer cargo async_zip 0.0.18 base/write/::ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#;
4 use craterust-analyzer cargo async_zip 0.0.18 crate/::errorrust-analyzer cargo async_zip 0.0.18 error/::{Zip64ErrorCaserust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#, ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#};
5 use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::constsrust-analyzer cargo async_zip 0.0.18 spec/consts/::NON_ZIP64_MAX_SIZErust-analyzer cargo async_zip 0.0.18 spec/consts/NON_ZIP64_MAX_SIZE.;
6 use craterust-analyzer cargo async_zip 0.0.18 crate/::testsrust-analyzer cargo async_zip 0.0.18 tests/::init_loggerrust-analyzer cargo async_zip 0.0.18 tests/init_logger().;
7 use craterust-analyzer cargo async_zip 0.0.18 crate/::testsrust-analyzer cargo async_zip 0.0.18 tests/::writerust-analyzer cargo async_zip 0.0.18 tests/write/::AsyncSinkrust-analyzer cargo async_zip 0.0.18 tests/write/AsyncSink#;
8 use craterust-analyzer cargo async_zip 0.0.18 crate/::{Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#, ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#};
9 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#;
10
11 use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::headerrust-analyzer cargo async_zip 0.0.18 spec/header/::ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#;
12 use futures_literust-analyzer cargo futures-lite 2.1.0 crate/::iorust-analyzer cargo futures-lite 2.1.0 io/::AsyncWriteExtrust-analyzer cargo futures-lite 2.1.0 io/AsyncWriteExt#;
13
14 // Useful constants for writing a large file.
15 const BATCH_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCH_SIZE.: usize = 100_000;
16 const NUM_BATCHESrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/NUM_BATCHES.: usize = NON_ZIP64_MAX_SIZErust-analyzer cargo async_zip 0.0.18 spec/consts/NON_ZIP64_MAX_SIZE. as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().BATCH_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCH_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1;
•17 const BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE.: u64 = NUM_BATCHESrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/NUM_BATCHES. as u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().BATCH_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCH_SIZE. as u64;
18
19 /// Test writing a small zip64 file.
20 /// No zip64 extra fields will be emitted for EntryWhole.
21 /// Z64 end of directory record & locator should be emitted
22 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
23 async fn test_write_zip64_filerust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_write_zip64_file().() {
24 init_loggerrust-analyzer cargo async_zip 0.0.18 tests/init_logger().();
25
26 let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
27 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut buffer).force_zip64rust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]force_zip64().();
28 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().("file1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
29 writer.write_entry_wholerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_whole().(entry, &[0, 0, 0, 0]).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
30 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().("file2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
31 let mut entry_writer = writer.write_entry_streamrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_stream().(entry).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
32 entry_writer.write_allrust-analyzer cargo futures-lite 2.1.0 io/AsyncWriteExt#write_all().(&[0, 0, 0, 0]).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
33 entry_writer.closerust-analyzer cargo async_zip 0.0.18 base/write/entry_stream/impl#[`EntryStreamWriter<'b, W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
34 writer.closerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
35
36 let cursor = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(buffer);
37 let mut zip = ziprust-analyzer cargo zip 5.1.1 crate/::readrust-analyzer cargo zip 5.1.1 read/::ZipArchiverust-analyzer cargo zip 5.1.1 read/zip_archive/ZipArchive#::newrust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]new().(cursor).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
38 let mut file1 = zip.by_namerust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]by_name().("file1").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
39 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(file1.extra_datarust-analyzer cargo zip 5.1.1 read/impl#[`ZipFile<'a, R>`]extra_data().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&[] as &[u8]));
40 let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
41 file1.read_to_endrust-analyzer cargo zip 5.1.1 read/impl#[`ZipFile<'_, R>`][Read]read_to_end().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
42 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buffer.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(), &[0, 0, 0, 0]);
43 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(file1);
44
45 let mut file2 = zip.by_namerust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]by_name().("file2").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
46 let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
47 file2.read_to_endrust-analyzer cargo zip 5.1.1 read/impl#[`ZipFile<'_, R>`][Read]read_to_end().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
48 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(buffer.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(), &[0, 0, 0, 0]);
49 }
50
51 /// Test writing a large zip64 file. This test will use upwards of 4GB of memory.
52 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
•53 #[cfg(not(target_pointer_width="32"))]
54 async fn test_write_large_zip64_filerust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_write_large_zip64_file().() {
55 init_loggerrust-analyzer cargo async_zip 0.0.18 tests/init_logger().();
56
57 // Allocate space with some extra for metadata records
•58 let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().((BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). 100_000).try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
59 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut buffer);
60
61 // Stream-written zip files are dubiously spec-conformant. We need to specify a valid file size
62 // in order for rs-zip (and unzip) to correctly read these files.
63 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().("file".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
64 let entry = entry.uncompressed_sizerust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]uncompressed_size().(BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. as u64);
65 let entry = entry.compressed_sizerust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]compressed_size().(BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. as u64);
66 let mut entry_writer = writer.write_entry_streamrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_stream().(entry).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
67 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NUM_BATCHESrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/NUM_BATCHES. {
68 entry_writer.write_allrust-analyzer cargo futures-lite 2.1.0 io/AsyncWriteExt#write_all().(&[0; BATCH_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCH_SIZE.]).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
69 }
70 entry_writer.closerust-analyzer cargo async_zip 0.0.18 base/write/entry_stream/impl#[`EntryStreamWriter<'b, W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
71
72 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(writer.is_zip64rust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#is_zip64.);
73 let cd_entry = writer.cd_entriesrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#cd_entries..lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
74 match &cd_entry.entryrust-analyzer cargo async_zip 0.0.18 base/write/CentralDirectoryEntry#entry..extra_fieldsrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#extra_fields..lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() {
75 ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#::Zip64ExtendedInformationrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#Zip64ExtendedInformation#(zip64) => {
76 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(zip64.compressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#compressed_size..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. as u64);
77 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(zip64.uncompressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#uncompressed_size..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. as u64);
78 }
79 e => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Expected a Zip64 extended field, got {:?}", e),
80 }
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cd_entry.headerrust-analyzer cargo async_zip 0.0.18 base/write/CentralDirectoryEntry#header..uncompressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#uncompressed_size., NON_ZIP64_MAX_SIZErust-analyzer cargo async_zip 0.0.18 spec/consts/NON_ZIP64_MAX_SIZE.);
82 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cd_entry.headerrust-analyzer cargo async_zip 0.0.18 base/write/CentralDirectoryEntry#header..compressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#compressed_size., NON_ZIP64_MAX_SIZErust-analyzer cargo async_zip 0.0.18 spec/consts/NON_ZIP64_MAX_SIZE.);
83 writer.closerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
84
85 let cursor = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(buffer);
86 let mut archive = ziprust-analyzer cargo zip 5.1.1 crate/::readrust-analyzer cargo zip 5.1.1 read/::ZipArchiverust-analyzer cargo zip 5.1.1 read/zip_archive/ZipArchive#::newrust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]new().(cursor).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
87 let mut file = archive.by_namerust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]by_name().("file").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
88 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(file.compressionrust-analyzer cargo zip 5.1.1 read/impl#[`ZipFile<'a, R>`]compression().(), ziprust-analyzer cargo zip 5.1.1 crate/::CompressionMethodrust-analyzer cargo zip 5.1.1 compression/CompressionMethod#::Storedrust-analyzer cargo zip 5.1.1 compression/CompressionMethod#Stored#);
89 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(file.sizerust-analyzer cargo zip 5.1.1 read/impl#[`ZipFile<'a, R>`]size().(), BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. as u64);
90 let mut buffer = [0; 100_000];
91 let mut bytes_total = 0;
92 loop {
93 let read_bytes = file.readrust-analyzer cargo zip 5.1.1 read/impl#[`ZipFile<'_, R>`][Read]read().(&mut buffer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
94 if read_bytes ==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). 0 {
95 break;
96 }
97 bytes_total +=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). read_bytes;
98 }
•99 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bytes_total as u64, BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE.);
100 }
101
102 /// Test writing a file, and reading it with async-zip
•103 /// Skip this test on 32-bit architectures as it will
104 /// Run out of address space.
105 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
•106 #[cfg(not(target_pointer_width="32"))]
107 async fn test_write_large_zip64_file_self_readrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_write_large_zip64_file_self_read().() {
108 use futures_literust-analyzer cargo futures-lite 2.1.0 crate/::iorust-analyzer cargo futures-lite 2.1.0 io/::AsyncReadExtrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#;
109
110 init_loggerrust-analyzer cargo async_zip 0.0.18 tests/init_logger().();
111
112 // Allocate space with some extra for metadata records
•113 let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().((BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). 100_000).try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
114 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut buffer);
115
116 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().("file".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
117 let mut entry_writer = writer.write_entry_streamrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_stream().(entry).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
118 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NUM_BATCHESrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/NUM_BATCHES. {
119 entry_writer.write_allrust-analyzer cargo futures-lite 2.1.0 io/AsyncWriteExt#write_all().(&[0; BATCH_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCH_SIZE.]).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
120 }
121 entry_writer.closerust-analyzer cargo async_zip 0.0.18 base/write/entry_stream/impl#[`EntryStreamWriter<'b, W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
122 writer.closerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
123
124 let reader = craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::memrust-analyzer cargo async_zip 0.0.18 base/read/mem/::ZipFileReaderrust-analyzer cargo async_zip 0.0.18 base/read/mem/ZipFileReader#::newrust-analyzer cargo async_zip 0.0.18 base/read/mem/impl#[ZipFileReader]new().(buffer).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
125 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(reader.filerust-analyzer cargo async_zip 0.0.18 base/read/mem/impl#[ZipFileReader]file().().zip64rust-analyzer cargo async_zip 0.0.18 file/ZipFile#zip64.);
126 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.filerust-analyzer cargo async_zip 0.0.18 base/read/mem/impl#[ZipFileReader]file().().entriesrust-analyzer cargo async_zip 0.0.18 file/ZipFile#entries.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..entryrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#entry..filenamerust-analyzer cargo async_zip 0.0.18 entry/impl#[ZipEntry]filename().().as_strrust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]as_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "file");
127 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(reader.filerust-analyzer cargo async_zip 0.0.18 base/read/mem/impl#[ZipFileReader]file().().entriesrust-analyzer cargo async_zip 0.0.18 file/ZipFile#entries.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..entryrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#entry..compressed_sizerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#compressed_size., BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE. as u64);
128 let mut entry = reader.reader_without_entryrust-analyzer cargo async_zip 0.0.18 base/read/mem/impl#[ZipFileReader]reader_without_entry().(0).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
129
130 let mut buffer = [0; 100_000];
131 let mut bytes_total = 0;
132 loop {
133 let read_bytes = entry.readrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#read().(&mut buffer).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadFuture<'_, R>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadFuture<'_, R>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
134 if read_bytes ==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). 0 {
135 break;
136 }
137 bytes_total +=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). read_bytes;
138 }
•139 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(bytes_total as u64, BATCHED_FILE_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCHED_FILE_SIZE.);
140 }
141
142 /// Test writing a zip64 file with more than u16::MAX files.
143 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
144 async fn test_write_zip64_file_many_entriesrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_write_zip64_file_many_entries().() {
145 init_loggerrust-analyzer cargo async_zip 0.0.18 tests/init_logger().();
146
147 // The generated file will likely be ~3MB in size.
148 let mut buffer = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(3_500_000);
149
150 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut buffer);
151 for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as u32 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). 1 {
152 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().(i.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
153 writer.write_entry_wholerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_whole().(entry, &[]).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
154 }
155 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(writer.is_zip64rust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#is_zip64.);
156 writer.closerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
157
158 let cursor = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(buffer);
159 let mut zip = ziprust-analyzer cargo zip 5.1.1 crate/::readrust-analyzer cargo zip 5.1.1 read/::ZipArchiverust-analyzer cargo zip 5.1.1 read/zip_archive/ZipArchive#::newrust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]new().(cursor).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
160 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(zip.lenrust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]len().(), u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 2);
161
162 for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as u32 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). 1 {
163 let mut file = zip.by_namerust-analyzer cargo zip 5.1.1 read/impl#[`ZipArchive<R>`]by_name().(&i.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
164 let mut buf = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
165 file.read_to_endrust-analyzer cargo zip 5.1.1 read/impl#[`ZipFile<'_, R>`][Read]read_to_end().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
166 }
167 }
168
169 /// Tests that EntryWholeWriter switches to Zip64 mode when writing too many files for a non-Zip64.
170 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
171 async fn test_zip64_when_many_files_wholerust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_zip64_when_many_files_whole().() {
172 let mut sink = AsyncSinkrust-analyzer cargo async_zip 0.0.18 tests/write/AsyncSink#;
173 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut sink);
174 for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as u32 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). 1 {
175 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{i}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
176 writer.write_entry_wholerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_whole().(entry, &[]).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
177 }
178 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(writer.is_zip64rust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#is_zip64.);
179 writer.closerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
180 }
181
182 /// Tests that EntryStreamWriter switches to Zip64 mode when writing too many files for a non-Zip64.
183 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
184 async fn test_zip64_when_many_files_streamrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_zip64_when_many_files_stream().() {
185 let mut sink = AsyncSinkrust-analyzer cargo async_zip 0.0.18 tests/write/AsyncSink#;
186 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut sink);
187 for i in 0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as u32 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). 1 {
188 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{i}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
189 let entrywriter = writer.write_entry_streamrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_stream().(entry).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
190 entrywriter.closerust-analyzer cargo async_zip 0.0.18 base/write/entry_stream/impl#[`EntryStreamWriter<'b, W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
191 }
192
193 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(writer.is_zip64rust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#is_zip64.);
194 writer.closerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
195 }
196
197 /// Tests that when force_no_zip64 is true, EntryWholeWriter errors when trying to write more than
198 /// u16::MAX files to a single archive.
199 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
200 async fn test_force_no_zip64_errors_with_too_many_files_wholerust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_force_no_zip64_errors_with_too_many_files_whole().() {
201 let mut sink = AsyncSinkrust-analyzer cargo async_zip 0.0.18 tests/write/AsyncSink#;
202 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut sink).force_no_zip64rust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]force_no_zip64().();
203 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. {
204 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{i}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
205 writer.write_entry_wholerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_whole().(entry, &[]).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
206 }
207 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().("65537".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
208 let result = writer.write_entry_wholerust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_whole().(entry, &[]).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
209
210 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(result, Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::Zip64Neededrust-analyzer cargo async_zip 0.0.18 error/ZipError#Zip64Needed#(Zip64ErrorCaserust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#::TooManyFilesrust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#TooManyFiles#))));
211 }
212
213 /// Tests that when force_no_zip64 is true, EntryStreamWriter errors when trying to write more than
214 /// u16::MAX files to a single archive.
215 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
216 async fn test_force_no_zip64_errors_with_too_many_files_streamrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_force_no_zip64_errors_with_too_many_files_stream().() {
217 let mut sink = AsyncSinkrust-analyzer cargo async_zip 0.0.18 tests/write/AsyncSink#;
218 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut sink).force_no_zip64rust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]force_no_zip64().();
219 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. {
220 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{i}").intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
221 let entrywriter = writer.write_entry_streamrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_stream().(entry).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
222 entrywriter.closerust-analyzer cargo async_zip 0.0.18 base/write/entry_stream/impl#[`EntryStreamWriter<'b, W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
223 }
224 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().("65537".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
225 let entrywriter = writer.write_entry_streamrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_stream().(entry).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
226 let result = entrywriter.closerust-analyzer cargo async_zip 0.0.18 base/write/entry_stream/impl#[`EntryStreamWriter<'b, W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
227
228 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(result, Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::Zip64Neededrust-analyzer cargo async_zip 0.0.18 error/ZipError#Zip64Needed#(Zip64ErrorCaserust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#::TooManyFilesrust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#TooManyFiles#))));
229 }
230
231 /// Tests that when force_no_zip64 is true, EntryStreamWriter errors when trying to write
232 /// a file larger than ~4 GiB to an archive.
233 #[tokiorust-analyzer cargo tokio 1.25.0 crate/::testrust-analyzer cargo tokio-macros 1.8.0 test:]
234 async fn test_force_no_zip64_errors_with_too_large_file_streamrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/test_force_no_zip64_errors_with_too_large_file_stream().() {
235 let mut sink = AsyncSinkrust-analyzer cargo async_zip 0.0.18 tests/write/AsyncSink#;
236 let mut writer = ZipFileWriterrust-analyzer cargo async_zip 0.0.18 base/write/ZipFileWriter#::newrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]new().(&mut sink).force_no_zip64rust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]force_no_zip64().();
237
238 let entry = ZipEntryBuilderrust-analyzer cargo async_zip 0.0.18 entry/builder/ZipEntryBuilder#::newrust-analyzer cargo async_zip 0.0.18 entry/builder/impl#[ZipEntryBuilder]new().("-".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored#);
239 let mut entrywriter = writer.write_entry_streamrust-analyzer cargo async_zip 0.0.18 base/write/impl#[`ZipFileWriter<W>`]write_entry_stream().(entry).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
240
241 // Writing 4GB, 1kb at a time
242 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#NUM_BATCHESrust-analyzer cargo async_zip 0.0.18 tests/write/zip64/NUM_BATCHES. {
243 entrywriter.write_allrust-analyzer cargo futures-lite 2.1.0 io/AsyncWriteExt#write_all().(&[0; BATCH_SIZErust-analyzer cargo async_zip 0.0.18 tests/write/zip64/BATCH_SIZE.]).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`WriteAllFuture<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
244 }
245 let result = entrywriter.closerust-analyzer cargo async_zip 0.0.18 base/write/entry_stream/impl#[`EntryStreamWriter<'b, W>`]close().().rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().;
246
247 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(result, Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::Zip64Neededrust-analyzer cargo async_zip 0.0.18 error/ZipError#Zip64Needed#(Zip64ErrorCaserust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#::LargeFilerust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#LargeFile#))));
248 }