Perseus commented on code in PR #3283:
URL: https://github.com/apache/iceberg-rust/pull/3283#discussion_r4537706274
##########
crates/iceberg/src/encryption/io.rs:
##########
@@ -74,8 +74,21 @@ impl EncryptedInputFile {
/// Creates a reader that transparently decrypts on each read.
pub async fn reader(&self) -> Result<Box<dyn FileRead>> {
+ // Identity just returns the file reader it was given.
+ self.reader_with_wrapper(std::convert::identity).await
+ }
+
+ /// Creates a decrypting reader, letting the caller wrap the file reader
first.
+ ///
+ /// Calls `wrap` once with the file reader and uses the result for
decryption.
+ /// This lets callers add behavior such as logging reads or counting bytes
+ /// without changing the decryption code.
+ pub(crate) async fn reader_with_wrapper(
+ &self,
+ wrap: impl FnOnce(Box<dyn FileRead>) -> Box<dyn FileRead>,
+ ) -> Result<Box<dyn FileRead>> {
Review Comment:
I tried to do this, but got
`impl Trait is not allowed in the parameters of Fn trait bound` from the
compiler. I've done a smaller change that *did* work, i.e, make the return
type of the closure use the generic `R`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]