blob: 4dd401354dc0b1ada1f59168362d388ec7730d15 [file] [log] [blame] [edit]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Virtual File System"><title>vfs - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-e56847b5.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="vfs" data-themes="" data-resource-suffix="" data-rustdoc-version="1.91.0 (f8297e351 2025-10-28)" data-channel="1.91.0" data-search-js="search-e256b49e.js" data-stringdex-js="stringdex-c3e638e9.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-6dc2a7f3.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Crate vfs</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../vfs/index.html">vfs</a><span class="version">0.0.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#virtual-file-system" title="Virtual File System">Virtual File System</a></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>vfs</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/vfs/lib.rs.html#1-329">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="virtual-file-system"><a class="doc-anchor" href="#virtual-file-system">§</a>Virtual File System</h2>
<p>VFS records all file changes pushed to it via <a href="struct.Vfs.html#method.set_file_contents" title="method vfs::Vfs::set_file_contents"><code>set_file_contents</code></a>.
As such it only ever stores changes, not the actual content of a file at any given moment.
All file changes are logged, and can be retrieved via
<a href="struct.Vfs.html#method.take_changes" title="method vfs::Vfs::take_changes"><code>take_changes</code></a> method. The pack of changes is then pushed to <code>salsa</code> and
triggers incremental recomputation.</p>
<p>Files in VFS are identified with <a href="struct.FileId.html" title="struct vfs::FileId"><code>FileId</code></a>s – interned paths. The notion of
the path, <a href="struct.VfsPath.html" title="struct vfs::VfsPath"><code>VfsPath</code></a> is somewhat abstract: at the moment, it is represented
as an <a href="https://doc.rust-lang.org/1.91.0/std/path/struct.PathBuf.html" title="struct std::path::PathBuf"><code>std::path::PathBuf</code></a> internally, but this is an implementation detail.</p>
<p>VFS doesn’t do IO or file watching itself. For that, see the <a href="loader/index.html" title="mod vfs::loader"><code>loader</code></a>
module. <a href="loader/trait.Handle.html" title="trait vfs::loader::Handle"><code>loader::Handle</code></a> is an object-safe trait which abstracts both file
loading and file watching. <a href="loader/trait.Handle.html" title="trait vfs::loader::Handle"><code>Handle</code></a> is dynamically configured with a set of
directory entries which should be scanned and watched. <a href="loader/trait.Handle.html" title="trait vfs::loader::Handle"><code>Handle</code></a> then
asynchronously pushes file changes. Directory entries are configured in
free-form via list of globs, it’s up to the <a href="loader/trait.Handle.html" title="trait vfs::loader::Handle"><code>Handle</code></a> to interpret the globs
in any specific way.</p>
<p>VFS stores a flat list of files. <a href="file_set/struct.FileSet.html" title="struct vfs::file_set::FileSet"><code>file_set::FileSet</code></a> can partition this list
of files into disjoint sets of files. Traversal-like operations (including
getting the neighbor file by the relative path) are handled by the <a href="file_set/struct.FileSet.html" title="struct vfs::file_set::FileSet"><code>FileSet</code></a>.
<a href="file_set/struct.FileSet.html" title="struct vfs::file_set::FileSet"><code>FileSet</code></a>s are also pushed to salsa and cause it to re-check <code>mod foo;</code>
declarations when files are created or deleted.</p>
<p><a href="file_set/struct.FileSet.html" title="struct vfs::file_set::FileSet"><code>FileSet</code></a> and <a href="loader/enum.Entry.html" title="enum vfs::loader::Entry"><code>loader::Entry</code></a> play similar, but different roles.
Both specify the “set of paths/files”, one is geared towards file watching,
the other towards salsa changes. In particular, single <a href="file_set/struct.FileSet.html" title="struct vfs::file_set::FileSet"><code>FileSet</code></a>
may correspond to several <a href="loader/enum.Entry.html" title="enum vfs::loader::Entry"><code>loader::Entry</code></a>. For example, a crate from
crates.io which uses code generation would have two <a href="loader/enum.Entry.html" title="enum vfs::loader::Entry"><code>Entries</code></a> – for sources
in <code>~/.cargo</code>, and for generated code in <code>./target/debug/build</code>. It will
have a single <a href="file_set/struct.FileSet.html" title="struct vfs::file_set::FileSet"><code>FileSet</code></a> which unions the two sources.</p>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="file_set/index.html" title="mod vfs::file_set">file_<wbr>set</a></dt><dd>Partitions a list of files into disjoint subsets.</dd><dt><a class="mod" href="loader/index.html" title="mod vfs::loader">loader</a></dt><dd>Dynamically compatible interface for file watching and reading.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.AbsPath.html" title="struct vfs::AbsPath">AbsPath</a></dt><dd>Wrapper around an absolute [<code>Utf8Path</code>].</dd><dt><a class="struct" href="struct.AbsPathBuf.html" title="struct vfs::AbsPathBuf">AbsPath<wbr>Buf</a></dt><dd>A [<code>Utf8PathBuf</code>] that is guaranteed to be absolute.</dd><dt><a class="struct" href="struct.AnchoredPath.html" title="struct vfs::AnchoredPath">Anchored<wbr>Path</a></dt><dd>Path relative to a file.</dd><dt><a class="struct" href="struct.AnchoredPathBuf.html" title="struct vfs::AnchoredPathBuf">Anchored<wbr>Path<wbr>Buf</a></dt><dd>Path relative to a file.</dd><dt><a class="struct" href="struct.ChangedFile.html" title="struct vfs::ChangedFile">Changed<wbr>File</a></dt><dd>Changed file in the <a href="struct.Vfs.html" title="struct vfs::Vfs"><code>Vfs</code></a>.</dd><dt><a class="struct" href="struct.FileId.html" title="struct vfs::FileId">FileId</a></dt><dd>Handle to a file in <a href="struct.Vfs.html" title="struct vfs::Vfs"><code>Vfs</code></a></dd><dt><a class="struct" href="struct.Vfs.html" title="struct vfs::Vfs">Vfs</a></dt><dd>Storage for all file changes and the file id to path mapping.</dd><dt><a class="struct" href="struct.VfsPath.html" title="struct vfs::VfsPath">VfsPath</a></dt><dd>Path in <a href="struct.Vfs.html" title="struct vfs::Vfs"><code>Vfs</code></a>.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.Change.html" title="enum vfs::Change">Change</a></dt><dd>Kind of <a href="struct.ChangedFile.html" title="struct vfs::ChangedFile">file change</a>.</dd><dt><a class="enum" href="enum.ChangeKind.html" title="enum vfs::ChangeKind">Change<wbr>Kind</a></dt><dd>Kind of <a href="struct.ChangedFile.html" title="struct vfs::ChangedFile">file change</a>.</dd><dt><a class="enum" href="enum.FileExcluded.html" title="enum vfs::FileExcluded">File<wbr>Excluded</a></dt><dt><a class="enum" href="enum.FileState.html" title="enum vfs::FileState">File<wbr>State</a></dt></dl></section></div></main></body></html>