pub enum FsRequest {
ReadDir {
id: NodeId,
path: PathBuf,
},
ReadFile {
buffer: BufferId,
path: PathBuf,
},
ReadPreview {
request: PreviewRequestId,
path: PathBuf,
line: usize,
context: usize,
},
ResolvePath {
request: LocationRequestId,
path: PathBuf,
},
WriteFile {
buffer: BufferId,
path: PathBuf,
contents: Vec<u8>,
version: u64,
},
Watch(PathBuf),
CreateFile(PathBuf),
CreateDir(PathBuf),
Rename {
from: PathBuf,
to: PathBuf,
},
Remove {
path: PathBuf,
recursive: bool,
},
Shutdown,
}Expand description
Work sent to the filesystem worker thread.
Intentionally not #[non_exhaustive]: this is internal vocabulary between our own
crates, and we want the compiler to flag every unhandled variant rather than letting
a wildcard arm swallow it.
Variants§
ReadDir
List one directory level for the tree node that asked for it.
ReadFile
Read a whole file for a buffer that is being opened.
Opening a file is blocking I/O like any other, so it goes through the worker rather than the render loop — a cold file on a network mount must not freeze the UI any more than a cold directory does (ADR-0005 §1).
ReadPreview
Read a small line window for a search-result preview without opening a buffer.
ResolvePath
Canonicalize a diagnostic path before the model decides whether it is safe to open inside the current workspace.
WriteFile
Write a buffer back to disk.
version is the buffer revision these bytes were taken from; it comes back on
FsEvent::FileSaved so the buffer only clears its dirty flag if nothing was
typed while the write was in flight. Carried as a raw u64 because core must
not depend on editor.
Watch(PathBuf)
Begin watching a root for changes.
CreateFile(PathBuf)
CreateDir(PathBuf)
Rename
Remove
Delete a file, or a directory and everything under it. The caller must have confirmed with the user first — the worker does not second-guess it.
Shutdown
Stop the worker. Sent on shutdown so the thread exits its loop cleanly.