pub struct FileId { /* private fields */ }Expand description
The identity of a file on one computer: the serial number of its volume and its 128-bit file
identifier, as GetFileInformationByHandleEx’s FileIdInfo class reported them.
Two values are equal when both fields are. What the fields mean beyond that is the call’s: the identifier is carried as its 16 bytes and is not read as an integer, which would impose a byte order the call does not state.
§Example
use win_durable_ioring::windows_backend::{Cached, FileOptions, OpenedFile};
use win_durable_ioring::Wtf16String;
let path = std::env::temp_dir().join(format!("file-id-doc-{}.tmp", std::process::id()));
std::fs::write(&path, b"x")?;
let name = || Wtf16String::from_os_str(path.as_os_str());
let first = OpenedFile::<Cached, _>::open(name(), FileOptions::new().read())?;
let second = OpenedFile::<Cached, _>::open(name(), FileOptions::new().read().write())?;
// Two opens of one file report one identity.
assert_eq!(first.file_id()?, second.file_id()?);Implementations§
Source§impl FileId
impl FileId
Sourcepub const fn new(volume_serial_number: u64, id: [u8; 16]) -> Self
pub const fn new(volume_serial_number: u64, id: [u8; 16]) -> Self
An identity with these fields, for a caller that holds them from elsewhere, such as a directory listing.
Sourcepub fn of(handle: &SharedHandle) -> Result<Self>
pub fn of(handle: &SharedHandle) -> Result<Self>
The identity of the file handle is open on, read on the calling thread through the handle,
which is shared for the call and not duplicated.
§Errors
The code the call failed with, unaltered. An event, a pipe, NUL and a volume were observed
refused; the FILE_ID_INFO page does not list the codes, so none is promised.
Sourcepub const fn volume_serial_number(&self) -> u64
pub const fn volume_serial_number(&self) -> u64
VolumeSerialNumber: the serial number of the volume that contains the file.