pub struct VfsRouter { /* private fields */ }Expand description
Routes filesystem operations to mounted backends.
Mount points are matched by longest prefix. For example, if /mnt and
/mnt/project are both mounted, a path like /mnt/project/src/main.rs
will be routed to the /mnt/project mount.
Implementations§
Source§impl VfsRouter
impl VfsRouter
Sourcepub fn mount(&mut self, path: impl Into<PathBuf>, fs: impl Filesystem + 'static)
pub fn mount(&mut self, path: impl Into<PathBuf>, fs: impl Filesystem + 'static)
Mount a filesystem at the given path.
The path should be absolute (start with /). If a filesystem is
already mounted at this path, it will be replaced.
Sourcepub fn mount_arc(&mut self, path: impl Into<PathBuf>, fs: Arc<dyn Filesystem>)
pub fn mount_arc(&mut self, path: impl Into<PathBuf>, fs: Arc<dyn Filesystem>)
Mount a filesystem (already wrapped in Arc) at the given path.
Sourcepub fn unmount(&mut self, path: impl AsRef<Path>) -> bool
pub fn unmount(&mut self, path: impl AsRef<Path>) -> bool
Unmount the filesystem at the given path.
Returns true if a mount was removed, false if nothing was mounted there.
Sourcepub fn list_mounts(&self) -> Vec<MountInfo>
pub fn list_mounts(&self) -> Vec<MountInfo>
List all current mounts.
Sourcepub fn resolve_real_path(&self, path: &Path) -> Option<PathBuf>
pub fn resolve_real_path(&self, path: &Path) -> Option<PathBuf>
Resolve a VFS path to a real filesystem path.
Returns Some(path) if the VFS path maps to a real filesystem (like LocalFs),
or None if the path is in a virtual filesystem (like MemoryFs).
This is needed for tools like git that must use real paths with external libraries.