impl Default for write::FileOptions
This commit is contained in:
parent
5d0f198124
commit
907e13b5b6
3 changed files with 10 additions and 4 deletions
|
@ -33,13 +33,13 @@ fn doit(filename: &str) -> zip::result::ZipResult<()>
|
||||||
|
|
||||||
let mut zip = zip::ZipWriter::new(file);
|
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);
|
let options = FileOptions::default().compression_method(zip::CompressionMethod::Stored).unix_permissions(0o755);
|
||||||
zip.start_file("test/☃.txt", options)?;
|
zip.start_file("test/☃.txt", options)?;
|
||||||
zip.write_all(b"Hello, World!\n")?;
|
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.write_all(LOREM_IPSUM)?;
|
||||||
|
|
||||||
zip.finish()?;
|
zip.finish()?;
|
||||||
|
|
|
@ -121,6 +121,12 @@ impl FileOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for FileOptions {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<W: Write+io::Seek> Write for ZipWriter<W>
|
impl<W: Write+io::Seek> Write for ZipWriter<W>
|
||||||
{
|
{
|
||||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize>
|
fn write(&mut self, buf: &[u8]) -> io::Result<usize>
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn end_to_end() {
|
||||||
fn write_to_zip_file(file: &mut Cursor<Vec<u8>>) -> zip::result::ZipResult<()> {
|
fn write_to_zip_file(file: &mut Cursor<Vec<u8>>) -> zip::result::ZipResult<()> {
|
||||||
let mut zip = zip::ZipWriter::new(file);
|
let mut zip = zip::ZipWriter::new(file);
|
||||||
|
|
||||||
zip.add_directory("test/", FileOptions::default())?;
|
zip.add_directory("test/", Default::default())?;
|
||||||
|
|
||||||
let options = FileOptions::default()
|
let options = FileOptions::default()
|
||||||
.compression_method(zip::CompressionMethod::Stored)
|
.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.start_file("test/☃.txt", options)?;
|
||||||
zip.write_all(b"Hello, World!\n")?;
|
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.write_all(LOREM_IPSUM)?;
|
||||||
|
|
||||||
zip.finish()?;
|
zip.finish()?;
|
||||||
|
|
Loading…
Add table
Reference in a new issue