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.
- Loading branch information
1 parent
6f59201
commit 542e930
Showing
5 changed files
with
133 additions
and
32 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
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,48 @@ | ||
// External | ||
use std::{ | ||
io::{ | ||
Write, | ||
Error | ||
} | ||
}; | ||
|
||
use crate::compression::Cleanup; | ||
|
||
pub fn signer_passthrough<T>(input: Result<T, Error>) -> Result<SignerPassthrough<T>, Error> | ||
where T: Write+Cleanup<T> | ||
{ | ||
match input { | ||
Err(e) => Err(e), | ||
Ok(input) => Ok( | ||
SignerPassthrough{ | ||
inner: input | ||
} | ||
) | ||
} | ||
} | ||
|
||
pub struct SignerPassthrough<T> | ||
where T: Write+Cleanup<T> | ||
{ | ||
inner: T | ||
} | ||
|
||
impl<T> Write for SignerPassthrough<T> | ||
where T: Write+Cleanup<T> | ||
{ | ||
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 SignerPassthrough<T> | ||
where T: Write+Cleanup<T> | ||
{ | ||
fn cleanup(self) -> Result<T, Error> { | ||
self.inner.cleanup() | ||
} | ||
} |