-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::io::{Read, Seek, Write}; | ||
|
||
use binrw::{BinResult, Endian}; | ||
use flate2::read::MultiGzDecoder; | ||
use flate2::write::GzEncoder; | ||
use flate2::Compression; | ||
|
||
use crate::BffResult; | ||
|
||
#[binrw::writer(writer)] | ||
pub fn gzip_compress_data_with_header_writer_internal(data: &[u8]) -> BinResult<()> { | ||
let mut gz = GzEncoder::new(writer, Compression::fast()); | ||
gz.write_all(data)?; | ||
Ok(()) | ||
} | ||
|
||
pub fn gzip_compress_data_with_header_writer<W: Write + Seek>( | ||
data: &[u8], | ||
writer: &mut W, | ||
endian: Endian, | ||
) -> BffResult<()> { | ||
Ok(gzip_compress_data_with_header_writer_internal( | ||
data, | ||
writer, | ||
endian, | ||
(), | ||
)?) | ||
} | ||
|
||
#[binrw::parser(reader)] | ||
pub fn gzip_decompress_data_with_header_parser_internal() -> BinResult<Vec<u8>> { | ||
let mut gz = MultiGzDecoder::new(reader); | ||
let mut buf = Vec::new(); | ||
gz.read_to_end(&mut buf)?; | ||
Ok(buf) | ||
} | ||
|
||
pub fn gzip_decompress_data_with_header_parser<R: Read + Seek>( | ||
reader: &mut R, | ||
endian: Endian, | ||
) -> BffResult<Vec<u8>> { | ||
Ok(gzip_decompress_data_with_header_parser_internal( | ||
reader, | ||
endian, | ||
(), | ||
)?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters