pub enum FileKind {
RegularFile {
file: RegularFile,
position: usize,
},
Directory {
dir: Directory,
position: usize,
},
Stdio,
Rx(Receiver<u8>),
Tx(Sender<u8>),
}Expand description
The type of a file in the filesystem.
This enum provides a way to distinguish between regular files and special files like standard input (stdin), standard output (stdout), standard error (stderr), and interprocess communication (IPC) channels such as pipes. It allows the system to treat these different types of files accordingly when performing file operations like reading, writing, or seeking.
Variants§
RegularFile
A regular file on the filesystem.
Fields
file: RegularFileA RegularFile object, which holds the underlying kernel
structure that represents the actual file in the kernel’s
memory. This structure contains additional metadata about
the file, such as its name.
position: usizeThe current position in the file (offset).
This field keeps track of the current position of the file pointer within the file. The position is measured in bytes from the beginning of the file. It is updated whenever a read or write operation is performed, allowing the system to track where the next operation will occur.
Example: If the file’s position is 100, the next read or write operation will begin at byte 100.
Directory
A directory of the filesystem.
This variant represents a directory in the filesystem. Unlike regular files, directories serve as containers for other files and directories. Operations on directories typically include listing contents, searching for files, and navigating file structures.
Fields
position: usizeThe current position in the directory (offset).
This field is internally used in readdir() function to track how much entries
Stdio
A special file for standard input/output streams.
This variant represents standard I/O streams like stdin, stdout, and stderr. These are not associated with physical files on disk but are used for interaction between processes and the console or terminal.
- Standard Input (
stdin): Used to receive user input. - Standard Output (
stdout): Used to display process output. - Standard Error (
stderr): Used to display error messages.
Rx(Receiver<u8>)
A receive endpoint for interprocess communication (IPC).
This variant represents a receiving channel in an IPC mechanism,
commonly used for message-passing between processes. It
acts as a read-only endpoint, allowing a process to receive data
from a corresponding FileKind::Tx (transmit) channel.
Data sent through the corresponding FileKind::Tx endpoint is
buffered and can be read asynchronously using this receiver. Once
all FileKind::Tx handles are closed, reads will return an
end-of-file (EOF) indication.
This is useful for implementing features like pipes, message queues, or event notifications.
Tx(Sender<u8>)
A transmit endpoint for interprocess communication (IPC).
This variant represents a sending channel in an IPC mechanism. It serves
as a write-only endpoint, allowing a process to send data to a
corresponding FileKind::Rx (receive) channel.
Data written to this FileKind::Tx endpoint is buffered until it is
read by the corresponding FileKind::Rx endpoint. If no receiver
exists, writes may block or fail depending on the system’s IPC
behavior.
This is commonly used in pipes, producer-consumer queues, and task synchronization mechanisms.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileKind
impl !RefUnwindSafe for FileKind
impl Send for FileKind
impl Sync for FileKind
impl Unpin for FileKind
impl !UnwindSafe for FileKind
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)