Replies: 3 comments
-
I don't know if there's really a great way to do this. When working with temp files you need keep them alive as long as you want the file to readable since they will be removed on |
Beta Was this translation helpful? Give feedback.
-
This might be a nuance of Rust I am unfamiliar with, so could you help clarify for me: Receives an If so, yeah, I can see the conundrum is that the temp file really has disappeared by then. I wish we had specialization with operator overloading, ha! But really I just wish we could alert some sort of "hey, be aware that maybe you just lost your temp file" warning, but idk. If it is something other than that, I'd love to understand it better, and maybe that will help. This is just such an easy gotcha to get caught on, and it took me quite a while to debug -- and the solution for me was simply to find the test cases to realize what I was missing, which does not seem like a high visibility insight, unfortunately. |
Beta Was this translation helpful? Give feedback.
-
Yeah that's correct. I've personally been caught up by NamedTempFile a number of times (although not on this particular API). It's definitely possible to add a Clippy lint for this. I'm surprised one hasn't been created already, honestly. |
Beta Was this translation helpful? Give feedback.
-
When using the
FsBuilder.path
, which is used byByteStream::from_path
, there can very easily be an unexpected error, that seems like it should be caught by the compiler rather than as a run time error.A
NamedTempFile
argument must be passed by reference (i.e. with a leading&
). If you remove the&
,ByteStream::from_path
(andFsBuilder.path
) will accept the argument, but immediately error out with anIoError
. You can demo this trivially with the existing tests, e.g. remove the&
from&file
on this line:smithy-rs/rust-runtime/aws-smithy-types/src/byte_stream/bytestream_util.rs
Line 323 in 23cdff1
Then running the tests with:
Will lead to this error:
Which seems very misleading, at best, and hopefully should be preventable at the compiler level by more appropriate typing -- or else adjusting as needed within the
FsBuilder.path
(orbuild
) function.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions