-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for temporary UNIX domain sockets #175
Comments
Thinking about this more, a generic let listener = tempfile::Builder::new()
.make(|path| UnixListener::bind(&path))?; Then, we just get back the type |
I think the generic In terms of builder functions, we'll need to support both We should define the function to take an tempfile::Builder::new().make(UnixListener::bind) Finally, I'd also:
(because it doesn't really hurt and may make it easier for users) |
I have a case where I want to create a temporary socket file which should be deleted when the server shuts down.
tempfile::NamedTempFile
doesn't work for this because you can't callUnixListener::bind(path)
on a file that already exists. It'd be great to havetempfile
handle the file path construction, but delegate thebind
to a callback function.For example, the API could look something like this:
And used like this:
If
NamedTempFile
gained a generic parameter (e.g.,NamedTempFile<F = File>
), then we could put the socket inside of that. I think this generic parameter could be a backward-compatible change, but I'm not sure. Such a change could come later, since the tuple above should work fine.Let me know what you think of this idea! This is generic enough to support more use cases beyond UNIX domain sockets, but I'm not sure what they are yet. There also shouldn't be any breaking changes introduced by this.
I'm happy to implement this if it seems reasonable.
The text was updated successfully, but these errors were encountered: