pub struct FileId(/* private fields */);Expand description
The identity of an existing file: device and inode on unix, volume serial number and file index on Windows.
Two ids are equal when the paths they were taken from name the same file: through a hard link, a symlink, a different case on a case-insensitive file system, or a relative and an absolute spelling.
A FileId holds an open handle to the file. On Windows the identity is valid only while that handle is open,
so keep the FileId alive for as long as it is compared. Creating many ids at once holds many open files.
same-file compares a 32-bit volume serial number and a 64-bit file index, but ReFS (Dev Drive) file ids are
128 bits, so two different files could compare equal there. Two ids therefore also have to agree on the file
length to be equal; a pair of different files of the same length on ReFS is the one case left undetected.
The length is read when two ids are compared, not when they are created (a growing temp file stays equal to
itself). Two ids compare equal only if both lengths can be read and match, so an id is not necessarily equal to
itself and the type is PartialEq only.
Implementations§
Source§impl FileId
impl FileId
Sourcepub fn of(path: &Path) -> Option<FileId>
pub fn of(path: &Path) -> Option<FileId>
The identity of the file at path (symlinks are followed), or None when it cannot be opened
(missing, removed meanwhile, no permission) or is neither a regular file nor a folder (a FIFO or
device is never opened). A file without an identity is never the same as another one.
Source§impl FileId
impl FileId
Sourcepub fn stdout() -> Option<FileId>
pub fn stdout() -> Option<FileId>
The identity of the file standard output is redirected to, or None unless that is a regular file: a
terminal, a device, a closed stdout or a failed duplicate all give None.
The identity is taken from a duplicate of the stdout descriptor (handle on Windows), owned by the returned
id, so dropping it never closes the process’s real stdout. On Windows a pipe or NUL may get an identity; a
pipe lives on the named-pipe file system’s volume and never matches a file on a disk volume, so nothing is
excluded (NUL is no disk file either, so an identity for it is harmless).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileId
impl RefUnwindSafe for FileId
impl Send for FileId
impl Sync for FileId
impl Unpin for FileId
impl UnsafeUnpin for FileId
impl UnwindSafe for FileId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more