turbo_tasks_fs/
virtual_fs.rs1use anyhow::{Result, bail};
2use turbo_rcstr::{RcStr, rcstr};
3use turbo_tasks::{ValueToString, Vc};
4
5use crate::{FileContent, FileMeta, FileSystem, FileSystemPath, LinkContent, RawDirectoryContent};
6
7#[derive(ValueToString)]
8#[value_to_string(self.name)]
9#[turbo_tasks::value]
10pub struct VirtualFileSystem {
11 pub name: RcStr,
12}
13
14impl VirtualFileSystem {
15 pub fn new() -> Vc<Self> {
24 Self::cell(VirtualFileSystem {
25 name: rcstr!("virtual file system"),
26 })
27 }
28
29 pub fn new_with_name(name: RcStr) -> Vc<Self> {
38 Self::cell(VirtualFileSystem { name })
39 }
40}
41
42#[turbo_tasks::value_impl]
43impl FileSystem for VirtualFileSystem {
44 #[turbo_tasks::function]
45 fn read(&self, _fs_path: FileSystemPath) -> Result<Vc<FileContent>> {
46 bail!("Reading is not possible on the virtual file system")
47 }
48
49 #[turbo_tasks::function]
50 fn read_link(&self, _fs_path: FileSystemPath) -> Result<Vc<LinkContent>> {
51 bail!("Reading is not possible on the virtual file system")
52 }
53
54 #[turbo_tasks::function]
55 fn raw_read_dir(&self, _fs_path: FileSystemPath) -> Result<Vc<RawDirectoryContent>> {
56 bail!("Reading is not possible on the virtual file system")
57 }
58
59 #[turbo_tasks::function]
60 fn write(&self, _fs_path: FileSystemPath, _content: Vc<FileContent>) -> Result<Vc<()>> {
61 bail!("Writing is not possible on the virtual file system")
62 }
63
64 #[turbo_tasks::function]
65 fn write_link(&self, _fs_path: FileSystemPath, _target: Vc<LinkContent>) -> Result<Vc<()>> {
66 bail!("Writing is not possible on the virtual file system")
67 }
68
69 #[turbo_tasks::function]
70 fn metadata(&self, _fs_path: FileSystemPath) -> Result<Vc<FileMeta>> {
71 bail!("Reading is not possible on the virtual file system")
72 }
73}