samgiles / rs-mktemp Goto Github PK
View Code? Open in Web Editor NEWmktemp for Rust
Home Page: https://docs.rs/mktemp/
License: Mozilla Public License 2.0
mktemp for Rust
Home Page: https://docs.rs/mktemp/
License: Mozilla Public License 2.0
Maybe something like
new_dir_in(&Path)
?
Or maybe a structure like
TempBuilder::new()
.in(&Path) // optional
.file() // or .dir
The default behaviour is nice for writing tests since everything is cleaned up afterwards. But painful if the tests fail -- it becomes hard to debug because it's not possible to see what is in the file that you've just deleted.
It would be nice to have a mechanism to stop file deletions after, say, a panic.
Hiya, this isn't an 'issue' but I wanted to ask about the design / what use cases you aim to cover.
First, some "mktemp" functions allow a template filename to be passed, e.g. C's mkstemp
and the shell command. Allowing this would be nice.
Second, there are several security issues to consider.
It may turn out better just to wrap C's mkstemp
or mkstemps
?
uuid 0.8 is deprecated since april 2022. Can it be upgraded?
The current implementation panic in the Drop
impl if removing the file failed. It panics even if the remove failed due to the file not existing. The purpose of the temp file is to make the file disappear, so why should that panic?
It’d be more efficient to have release()
consume self
and return the PathBuf
:
pub fn release(self) -> PathBuf {
let path = mem::replace(&mut self.path, PathBuf::new());
mem::forget(self);
path
}
That way you don’t need to allocate twice just to get the path out as a PathBuf
.
This also allows you to scrap the flag _release
altogether.
I guess it would make sense releasing a new version just to get rid of the old uuid
dependency,...
Fix is already commited to master, but crates.io update is not done. v5.1 would fix that.
The _type
flag is wasteful and makes for trivially more expensive construction and destruction. It’d be more efficient—and I would argue more ergonomic—to split the Temp
type into two types, TempFile
and TempDir
. (I’m not going to suggest phantom types, because they’re more complex for no gain that is evident to me.)
I have a use case where I'm generating a temporary file and then opening it with a text editor. The editor uses the file extension to decide which syntax highlighter to use so it would be useful to be able to specify the extension by hand.
Is this project still alive?...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.