impl Default for write::FileOptions

This commit is contained in:
Michael Lamparski 2019-07-22 13:24:34 -04:00
parent 5d0f198124
commit 907e13b5b6
3 changed files with 10 additions and 4 deletions

View file

@ -33,13 +33,13 @@ fn doit(filename: &str) -> zip::result::ZipResult<()>
let mut zip = zip::ZipWriter::new(file);
zip.add_directory("test/", FileOptions::default())?;
zip.add_directory("test/", Default::default())?;
let options = FileOptions::default().compression_method(zip::CompressionMethod::Stored).unix_permissions(0o755);
zip.start_file("test/☃.txt", options)?;
zip.write_all(b"Hello, World!\n")?;
zip.start_file("test/lorem_ipsum.txt", FileOptions::default())?;
zip.start_file("test/lorem_ipsum.txt", Default::default())?;
zip.write_all(LOREM_IPSUM)?;
zip.finish()?;

View file

@ -121,6 +121,12 @@ impl FileOptions {
}
}
impl Default for FileOptions {
fn default() -> Self {
Self::default()
}
}
impl<W: Write+io::Seek> Write for ZipWriter<W>
{
fn write(&mut self, buf: &[u8]) -> io::Result<usize>

View file

@ -20,7 +20,7 @@ fn end_to_end() {
fn write_to_zip_file(file: &mut Cursor<Vec<u8>>) -> zip::result::ZipResult<()> {
let mut zip = zip::ZipWriter::new(file);
zip.add_directory("test/", FileOptions::default())?;
zip.add_directory("test/", Default::default())?;
let options = FileOptions::default()
.compression_method(zip::CompressionMethod::Stored)
@ -28,7 +28,7 @@ fn write_to_zip_file(file: &mut Cursor<Vec<u8>>) -> zip::result::ZipResult<()> {
zip.start_file("test/☃.txt", options)?;
zip.write_all(b"Hello, World!\n")?;
zip.start_file("test/lorem_ipsum.txt", FileOptions::default())?;
zip.start_file("test/lorem_ipsum.txt", Default::default())?;
zip.write_all(LOREM_IPSUM)?;
zip.finish()?;