12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ #![ warn( missing_docs) ]
16
+
15
17
//! Manipulate Unix file mode bits.
16
18
//!
17
19
//! Every filesystem entry (or inode) on Unix has a bit field of
27
29
//! ```
28
30
//!
29
31
//! The encoding is fairly standard across unices, and occurs in some file
30
- //! formats and network protocols that might be seen on non-Unix platforms.
32
+ //! formats and network protocols that might be seen on non-Unix platforms, including that of
33
+ //! `rsync`.
31
34
//!
32
35
//! This library isn't Unix-specific and doesn't depend on the underlying OS to
33
36
//! interpret the bits.
47
50
//! * More tests.
48
51
//! * Move changelog into Rustdoc.
49
52
//!
50
- //! ## 0.1.2 2021-08-1
53
+ //! ## 0.1.2
51
54
//!
52
55
//! * Add [is_setuid], [is_setgid], [is_sticky].
53
56
//!
@@ -73,14 +76,21 @@ fn type_bits(mode: u32) -> u32 {
73
76
#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
74
77
#[ non_exhaustive]
75
78
pub enum Type {
79
+ /// A plain file.
76
80
File ,
81
+ /// A directory.
77
82
Dir ,
83
+ /// A symbolic link.
78
84
Symlink ,
85
+ /// A Unix-domain socket.
79
86
Socket ,
87
+ /// A named pipe / FIFO.
80
88
Fifo ,
89
+ /// A block device, such as a disk.
81
90
BlockDevice ,
91
+ /// A character device, such as a `/dev/null`.
82
92
CharDevice ,
83
- /// Removed file in union filesystems
93
+ /// A removed file in union filesystems.
84
94
Whiteout ,
85
95
/// File type not recognized by this version of this library
86
96
///
@@ -110,17 +120,25 @@ impl From<u32> for Type {
110
120
/// Enum for specifying the context / "who" accesses in [is_allowed]
111
121
#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
112
122
pub enum Accessor {
123
+ /// Access by anyone other than the user or group.
113
124
Other ,
125
+ /// Access by the group of the file.
114
126
Group ,
127
+ /// Access by the owner of the file.
115
128
User ,
116
129
}
117
130
118
131
/// Enum for specifying the type of access in [is_allowed]
119
132
#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
120
133
pub enum Access {
121
- /// (Beware: execute has various meanings depending on the type of file)
134
+ /// Permission to "execute", broadly.
135
+ ///
136
+ /// For plain files, this does mean permission to execute. For directories, this grants
137
+ /// permission to open files within the directory whose name is known.
122
138
Execute ,
139
+ /// Permission to write the file.
123
140
Write ,
141
+ /// Permission to read the file, or to read the names of files in a directory.
124
142
Read ,
125
143
}
126
144
0 commit comments