standard_lib/fs/file/
mod.rs

1//! Types for interacting with files (or file-like inodes) on a file system. Primarily revolves
2//! around the [`File`] type and accompanying access mode markers.
3//! 
4//! This module provides the [`File`] type and various associated types, including markers, errors
5//! and builders.
6//!
7//! # Opening
8//! Although some convenience methods are provided on `File` itself, the full open functionality is
9//! available via the [`OpenOptions`] builder (obtainable via [`File::options`]).
10//! 
11//! Files can be opened from an absolute path ([`Path<Abs>`](crate::fs::Path)), relative path and
12//! directory ([`Path<Rel>`](crate::fs::Path), [`Directory`](crate::fs::Directory)) or a directory
13//! entry ([`DirEntry`](crate::fs::dir::DirEntry)).
14//!
15//! # Closing
16//! `File`s, despite not visibly implementing [`Drop`], ensure that the associated file is closed
17//! when they are dropped, and can panic if an error occurs. To close a file with error handling,
18//! the [`close`](File::close) method can be used instead.
19//! 
20//! It is also important to note that due to Linux file system behavior, closing a file does not
21//! guarantee that it's data is written to disk. If this is important, please ensure that
22//! [`sync`](File::sync) is called before closing.
23//!
24//! # Access Mode
25//! Each file is associated with an AccessMode, which takes the form of a generic type parameter.
26//! There are three available modes: [`ReadOnly`](super::ReadOnly), [`WriteOnly`](super::WriteOnly)
27//! and [`ReadWrite`], representing those exposed by the Linux syscalls. Wherever applicable, the
28//! default mode is `ReadWrite`. Along with these types, there are also two traits seen in the
29//! public API, `Read` and `Write`. It is unlikely that these type need to be used directly, but
30//! instead act as markers for the available modes to allow overlapping implications.
31
32mod access;
33mod error;
34mod file;
35mod options;
36
37pub use access::*;
38pub use error::*;
39pub use file::*;
40pub use options::*;