1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2026 Mike Grier
//! [`Disposition`]: what an open does about a file that is there and a file that is not, as
//! `CreateFileW`'s `dwCreationDisposition` states it (DI-13.7.3, DI-D-64).
//!
//! `CreateFileW` has five dispositions. Three are offered here. `CREATE_ALWAYS` and
//! `TRUNCATE_EXISTING` are the two that empty a file that exists, and they are not offered in the
//! first release (the engineer's ruling of 2026-10-16, recorded with its measurements in DI-D-64);
//! the enum is `#[non_exhaustive]` so that offering them later is not a breaking change. A caller
//! that wants an existing file emptied does it through the handle the open lends, with
//! `File::set_len(0)`.
use ;
/// The disposition of an open: what it does when the file exists and when it does not.
///
/// None of the three changes the contents of a file that exists, so no data access is gated by the
/// choice.
///
/// | Variant | `dwCreationDisposition` | File exists | File does not exist |
/// |---|---|---|---|
/// | [`CreateNew`](Self::CreateNew) | `CREATE_NEW` | fails, `ERROR_FILE_EXISTS` | created |
/// | [`OpenExisting`](Self::OpenExisting) | `OPEN_EXISTING` | opened | fails, `ERROR_FILE_NOT_FOUND` |
/// | [`OpenAlways`](Self::OpenAlways) | `OPEN_ALWAYS` | opened | created |
///
/// A file that an open creates is created empty.
///
/// There is deliberately no `Default`: the options start at [`OpenExisting`](Self::OpenExisting),
/// which creates nothing, and a disposition is stated where one is wanted.