-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from ggtools/main
✨ Add support of zstandard
- Loading branch information
Showing
7 changed files
with
54 additions
and
6 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,22 @@ | ||
use crate::oneio::compressions::OneIOCompression; | ||
use crate::OneIoError; | ||
use std::fs::File; | ||
use std::io::{BufWriter, Read, Write}; | ||
|
||
pub(crate) struct OneIOZstd; | ||
|
||
impl OneIOCompression for OneIOZstd { | ||
fn get_reader(raw_reader: Box<dyn Read + Send>) -> Result<Box<dyn Read + Send>, OneIoError> { | ||
match zstd::Decoder::new(raw_reader) { | ||
Ok(dec) => Ok(Box::new(dec)), | ||
Err(e) => Err(OneIoError::IoError(e)), | ||
} | ||
} | ||
|
||
fn get_writer(raw_writer: BufWriter<File>) -> Result<Box<dyn Write>, OneIoError> { | ||
match zstd::Encoder::new(raw_writer, 9) { | ||
Ok(dec) => Ok(Box::new(dec.auto_finish())), | ||
Err(e) => Err(OneIoError::IoError(e)), | ||
} | ||
} | ||
} |
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
Binary file not shown.