forked from SteveGremory/Zap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished generic compression algorithms.
- Loading branch information
1 parent
5fc7afe
commit 9204129
Showing
8 changed files
with
80 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
// Internal | ||
use super::Cleanup; | ||
|
||
// External | ||
use std::io::{ | ||
Error, | ||
ErrorKind, | ||
Write, | ||
}; | ||
use lz4_flex::frame::{ | ||
FrameEncoder, | ||
FrameDecoder | ||
}; | ||
|
||
pub fn lz4_encoder<T>(input: Result<T, std::io::Error>) -> Result<Lz4_Encoder<T>, std::io::Error> | ||
where T: Write | ||
{ | ||
Ok( Lz4_Encoder { | ||
inner: (FrameEncoder::new(input?)) | ||
}) | ||
} | ||
|
||
pub struct Lz4_Encoder<T> | ||
where T: Write | ||
{ | ||
inner: FrameEncoder<T> | ||
} | ||
|
||
impl<T> Write for Lz4_Encoder<T> | ||
where T: Write | ||
{ | ||
fn flush(&mut self) -> std::io::Result<()> { | ||
self.inner.flush() | ||
} | ||
|
||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { | ||
self.inner.write(buf) | ||
} | ||
} | ||
|
||
impl<T> Cleanup<T> for Lz4_Encoder<T> | ||
where T: Write | ||
{ | ||
fn cleanup(self) -> Result<T, Error> | ||
{ | ||
match self.inner.finish() | ||
{ | ||
Ok(w) => Ok(w), | ||
Err(e) => Err(Error::from( | ||
ErrorKind::Interrupted | ||
)) | ||
} | ||
} | ||
} |
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
Empty file.
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 |
---|---|---|
|
@@ -8,7 +8,3 @@ use openssl::{ | |
|
||
}; | ||
|
||
pub fn encrypt(input: String) | ||
{ | ||
|
||
} |
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