Getting around File::try_clone simantics

I am writing a test where a create a file using tempfile. I clone the file with try_clone (docs) and then pass it to a system that I am testing. I then want to test that some data was written. To do this I have to rewind the original file because try_clone creates a file from the same file handle so seek position is synced.

I was wondering if there is any way around this. It can be annoying to remember to seek to the beginning. I also might want to test what is written in the middle of the other system writing to the file. If I knew the path than I could open the file twice rather than using try_clone but I can't get the path for a temporary file.

Perhaps the FileExt::read_exact_at and FileExt::write_all_at methods would be useful?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.