-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Document and expand the open options #1252
Conversation
@pitdicker Thanks so much for taking this on; it's clearly a huge amount of work! I'm excited to dig into the details and hope to leave feedback soon. |
### Create | ||
`.create(true)` | ||
|
||
Open an existing file, or create a new file if it already exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/if it already exist/if it doesn’t exist/?
Also some spelling fixes, and two comments from @nagisa
And a few small nits
Sorry for making some more commits to the RFC, I am clearly an amateur... |
Just a note about an issue I ran into today. Opening a path to a directory as a file has different results on different platforms, and should be documented also. I was only able to test UNIX, but the results on UNIX were:
|
The documentation here is pretty extensive. Is it worth mentioning how Also, wouldn't it be better to yield an error if people start mixing flags in broken ways? |
@withoutboats, @ehiggs thanks for your comments! @withoutboats @ehiggs In this case I think it is best to return an error if |
IMO it can be thought about in a way that makes sense:
The fact that |
@nagisa Yes, |
It need not be an error, but could be a lint. I'll open an issue over at clippy for now. |
Would be nice to somehow advance it since the discussion has stalled. Could it be possible to include into schedule of the next libs team meeting/do a FCP? |
I realised I never answered your question. I fear I’ve forgotten my original point. Here’s the current thoughts (that may or may not differ from whatever I said earlier): In case where two options are mutually exclusive, it is always possible to encode that in the API by removing the possible intersection point. In case of
However, since we are bound by stability guarantees, I guess simply panicking in the builder finalizer (the |
Just a heads-up: clippy now contains a nonsensical_open_option lint. |
I don't see why the exact conflicting-options-behaviour (supercede, one takes priority...) matters as long as it is well documented. Anyway, looks like an amazing API (from my semi-ignorant viewpoint). I'd offer to help with impl/testing (Linux) but it looks like you're way ahead of me. |
`.share_mode(DENY_READ | DENY_WRITE | DENY_DELETE)`. | ||
|
||
|
||
## Caching behaviour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate a bit on the inclusion of these new options? I would personally expect this to fall under the category of "out of scope for now" in the sense that this should all in theory be possible to implement externally (e.g. using the as-raw-os-handle style traits).
Sorry for taking so look to get around to this @pitdicker, but it all looks great to me! It'd be nice to have a concise overview of the OS-specific extension traits in terms of what the APIs would look like, but I think it's also relatively easy to infer to it's not critical. I agree with @nagisa and I'll try to bring this up soon at a libs team meeting to move into FCP. |
Everyone thanks for the comments and pursuing. Sorry for not doing this I have changed my opinion about 'no access mode set'. It does not really have Also, I have rewritten the caching part of the rfc, put not yet pushed. |
@llogiq I keep being amazed how much you can lint for! Very nice to see a nonsensical_open_option lint. |
I'd be fine with no access mode == error, I think we'd definitely be able to expand that in the future to return success if an interesting case came up. I'd also be ok leaving the caching/file locking to a separate RFC, although ensuring there's design space for it is fine to mention (although with a builder-style thing we should be pretty set) |
@pitdicker We haven't even made a dent in the surface of what can be linted. The Btw. if you see other APIs that have ambiguous or confusing API items, just file a clippy issue, no matter if you think it possible to lint or not. |
@pitdicker I have no clue who would make use of the Windows-specific share mode. It replaces one set of problems with another, though I guess it would be nice to know writes wouldn't collide (if this could be done cross-platform). Speaking of which, the atomic append operations appear to be limited in length. See here and specifically here. Anywhere from 256 bytes to 4k. Makes it useless for what I wanted to do, but anyway. |
@dhardy I did some testing for the length of atomic append because of these posts, and did not find a limit. I think they found a limit because that language uses buffered IO or a pipe with a buffer. |
@pitdicker great news. Sounds like it should be tested on a few different platforms still. |
@llogiq, @Pyriphlegethon: that's great news about the lint. My concern about nonsensical flags are basically solved. Thanks! |
Well, in a perfect world, a lint wouldn't be needed, but when using the type system isn't possible (in this case because of backwards-compatibility), it's the best we can do. |
🔔 This RFC is now entering its week-long final comment period 🔔 |
The libs team discussed this during triage today and the decision was to merge. @pitdicker would you be ok moving the sections about caching and such to alternatives as well? We were thinking that for now we may not want to dive into those domains but it's certainly possible in the future! |
@alexcrichton Great news! |
I have a local branch with most of the changes proposed by this rfc, but it is messy and I don't have time to clean it up before the Christmas holidays. If anyone wants to implement it, let me know. Maybe you can use it as a starting point... |
Looks good to me, thanks @pitdicker! Feel free to send the PR whenever, and thanks so much again for the RFC! |
The options that can be passed to the os when opening a file vary between
systems. And even if the options seem the same or similar, there may be
unexpected corner cases.
This RFC attempts to
systems.
rendered