turbo_tasks_fs/
virtual_fs.rs1use anyhow::{Result, bail};
2use turbo_rcstr::{RcStr, rcstr};
3use turbo_tasks::{ValueDefault, 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
42impl ValueDefault for VirtualFileSystem {
43 fn value_default() -> Vc<Self> {
44 Self::new()
45 }
46}
47
48#[turbo_tasks::value_impl]
49impl FileSystem for VirtualFileSystem {
50 #[turbo_tasks::function]
51 fn read(&self, _fs_path: FileSystemPath) -> Result<Vc<FileContent>> {
52 bail!("Reading is not possible on the virtual file system")
53 }
54
55 #[turbo_tasks::function]
56 fn read_link(&self, _fs_path: FileSystemPath) -> Result<Vc<LinkContent>> {
57 bail!("Reading is not possible on the virtual file system")
58 }
59
60 #[turbo_tasks::function]
61 fn raw_read_dir(&self, _fs_path: FileSystemPath) -> Result<Vc<RawDirectoryContent>> {
62 bail!("Reading is not possible on the virtual file system")
63 }
64
65 #[turbo_tasks::function]
66 fn write(&self, _fs_path: FileSystemPath, _content: Vc<FileContent>) -> Result<Vc<()>> {
67 bail!("Writing is not possible on the virtual file system")
68 }
69
70 #[turbo_tasks::function]
71 fn write_link(&self, _fs_path: FileSystemPath, _target: Vc<LinkContent>) -> Result<Vc<()>> {
72 bail!("Writing is not possible on the virtual file system")
73 }
74
75 #[turbo_tasks::function]
76 fn metadata(&self, _fs_path: FileSystemPath) -> Result<Vc<FileMeta>> {
77 bail!("Reading is not possible on the virtual file system")
78 }
79}