Sourced from tempfile's changelog.
3.4.0
SECURITY: Prior
tempfile
releases depended onremove_dir_all
version 0.5.0 which was vulnerable to a TOCTOU race. This same race is present in rust versions prior to 1.58.1.Features:
- Generalized temporary files:
NamedTempFile
can now abstract over different kinds of files (e.g., unix domain sockets, pipes, etc.):
- Add
Builder::make
andBuilder::make_in
for generalized temp file creation.- Add
NamedTempFile::from_parts
to complementNamedTempFile::into_parts
.- Add generic parameter to
NamedTempFile
to support wrapping non-File types.Bug Fixes/Improvements:
- Don't try to create a temporary file multiple times if the file path has been fully specified by the user (no random characters).
NamedTempFile::persist_noclobber
is now always atomic on linux whenrenameat_with
is supported. Previously, it would first link the new path, then unlink the previous path.- Fix compiler warnings on windows.
Trivia:
- Switch from
libc
torustix
on wasi/unix. This now makes direct syscalls instead of calling through libc.- Remove
remove_dir_all
dependency. The rust standard library has optimized their internal version significantly.- Switch to official windows-sys windows bindings.
Breaking:
- The minimum rust version is now
1.48.0
.- Mark most functions as
must_use
.- Uses direct syscalls on linux by default, instead of libc.
- The new type parameter in
NamedTempFile
may lead to type inference issues in some cases.