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