pub struct DiskFileSystem { /* private fields */ }Expand description
DiskFileSystem carries serializable fields (name, root,
denied_paths) inside DiskFileSystemInner alongside session-scoped
state (the notify watcher, invalidator maps, weak TurboTasksApi,
etc.) This is important to maintain invariants in a session and ensure invalidations work, so we
never evict this data.
Implementations§
Source§impl DiskFileSystem
impl DiskFileSystem
pub fn name(&self) -> &RcStr
pub fn root(&self) -> &RcStr
pub fn invalidate(&self)
pub fn invalidate_with_reason<R: InvalidationReason + Clone>( &self, reason: impl Fn(&Path) -> R + Sync, )
pub fn invalidate_path_and_children_with_reason<R: InvalidationReason + Clone>( &self, paths: impl IntoIterator<Item = PathBuf>, reason: impl Fn(&Path) -> R + Sync, )
pub async fn start_watching(&self) -> Result<()>
pub async fn stop_watching(&self)
Sourcepub fn try_from_sys_path(
&self,
vc_self: ResolvedVc<DiskFileSystem>,
sys_path: &Path,
relative_to: Option<&FileSystemPath>,
) -> Option<FileSystemPath>
pub fn try_from_sys_path( &self, vc_self: ResolvedVc<DiskFileSystem>, sys_path: &Path, relative_to: Option<&FileSystemPath>, ) -> Option<FileSystemPath>
Try to convert Path to FileSystemPath. Return None if the file path leaves the
filesystem root. If no relative_to argument is given, it is assumed that the sys_path is
relative to the DiskFileSystem root.
Attempts to convert absolute paths to paths relative to the filesystem root, though we only attempt to do so lexically.
Assumes self is the DiskFileSystem contained in vc_self. This API is a bit awkward
because:
Path/PathBufshould not be stored in the filesystem cache, so the function cannot be aturbo_tasks::function.- It’s a little convenient for this function to be sync.
Sourcepub async fn try_from_sys_path_across_roots(
&self,
vc_self: ResolvedVc<DiskFileSystem>,
sys_path: &Path,
relative_to: &FileSystemPath,
) -> Result<Option<FileSystemPath>>
pub async fn try_from_sys_path_across_roots( &self, vc_self: ResolvedVc<DiskFileSystem>, sys_path: &Path, relative_to: &FileSystemPath, ) -> Result<Option<FileSystemPath>>
Similar to try_from_sys_path, but allows resolving paths that cross roots and may be in
a different DiskFileSystem linked via the DiskFileSystemMap.
Unlike try_from_sys_path, this conversion is not entirely lexical, and we may attempt to
canonicalize some segments of an absolute path.
Crossing roots should generally only happen at symlink boundaries. If you are not
handling a path that was potentially formed by crossing a symlink boundary, you should
prefer try_from_sys_path.
Sourcepub fn to_sys_path_raw(&self, fs_path: &FileSystemPath) -> PathBuf
pub fn to_sys_path_raw(&self, fs_path: &FileSystemPath) -> PathBuf
Returns the path as a system PathBuf. Similar to DiskFileSystem::to_sys_path, but
keeps the internal representation as-is.
On Windows this returns the verbatim/extended (\\?\-prefixed) path format used internally,
which supports paths exceeding the 260 character path limit. Use this for internal
filesystem operations and for comparisons against other internal paths, such as the keys of
the invalidator maps used by Self::invalidate_path_and_children_with_reason. For a path
handed to external consumers, prefer Self::to_sys_path.
On non-Windows platforms this is identical to Self::to_sys_path.
Sourcepub fn to_sys_path(&self, fs_path: &FileSystemPath) -> PathBuf
pub fn to_sys_path(&self, fs_path: &FileSystemPath) -> PathBuf
Returns the path as a system PathBuf.
As a general rule, system paths should not be stored inside turbo-task cells, or passed
inside [turbo_tasks::TaskInput]s as they are not valid after serialization.
On Windows, this will attempt to convert the internal verbatim/extended path representation to a more-compatible win32 path, but may return a verbatim path if that conversion fails.
Source§impl DiskFileSystem
impl DiskFileSystem
Sourcepub fn new(name: RcStr, root: Vc<RcStr>) -> Vc<Self>
pub fn new(name: RcStr, root: Vc<RcStr>) -> Vc<Self>
Create a new instance of DiskFileSystem.
name is a display name for the filesystem. This should be unique.
root is the canonicalized root of the filesystem. It should have
a stable [cell identity][ResolvedVc] to avoid invalidating every path if the root changes.
This API does not canonicalize itself, as that requires IO operations (e.g. symlink resolution) which should (ideally) not be cached.
Sourcepub fn new_with_options(
name: RcStr,
root: Vc<RcStr>,
denied_paths: Vec<RcStr>,
watcher_config: DiskWatcherConfig,
map: OperationVc<DiskFileSystemMap>,
) -> Vc<Self>
pub fn new_with_options( name: RcStr, root: Vc<RcStr>, denied_paths: Vec<RcStr>, watcher_config: DiskWatcherConfig, map: OperationVc<DiskFileSystemMap>, ) -> Vc<Self>
An extended version of DiskFileSystem::new.
denied_paths contains normalized Unix-style paths relative to root that
DiskFileSystem will treat as nonexistent, disallowing reads of files in those
directories.
watcher_config controls how filesystem changes are detected and reported. See
DiskWatcherConfig.
map provides other configured filesystems used to resolve symlink targets that leave
this filesystem’s root.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for DiskFileSystem
impl<'__de, __Context> BorrowDecode<'__de, __Context> for DiskFileSystem
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Source§impl Clone for DiskFileSystem
impl Clone for DiskFileSystem
Source§fn clone(&self) -> DiskFileSystem
fn clone(&self) -> DiskFileSystem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DiskFileSystem
impl Debug for DiskFileSystem
Source§impl<__Context> Decode<__Context> for DiskFileSystem
impl<__Context> Decode<__Context> for DiskFileSystem
Source§impl Encode for DiskFileSystem
impl Encode for DiskFileSystem
Source§impl FileSystem for DiskFileSystem
impl FileSystem for DiskFileSystem
fn read(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<FileContent>
fn raw_read_dir( self: Vc<Self>, fs_path: FileSystemPath, ) -> Vc<RawDirectoryContent>
Source§fn read_link(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<LinkContent>
fn read_link(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<LinkContent>
LinkContent.Source§fn is_junction_point(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<bool>
fn is_junction_point(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<bool>
false on all other
platforms.fn write( self: Vc<Self>, fs_path: FileSystemPath, content: Vc<FileContent>, ) -> Vc<()>
Source§fn write_link(
self: Vc<Self>,
fs_path: FileSystemPath,
target: Vc<WriteLinkContent>,
) -> Vc<()>
fn write_link( self: Vc<Self>, fs_path: FileSystemPath, target: Vc<WriteLinkContent>, ) -> Vc<()>
WriteLinkContent and FileSystemPath::write_link.fn metadata(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<FileMeta>
Source§fn root(self: Vc<Self>) -> Vc<FileSystemPath>where
Self: Sized,
fn root(self: Vc<Self>) -> Vc<FileSystemPath>where
Self: Sized,
impl NonLocalValue for DiskFileSystem
Source§impl ShrinkToFit for DiskFileSystem
impl ShrinkToFit for DiskFileSystem
fn shrink_to_fit(&mut self)
impl Upcast<Box<dyn FileSystem>> for DiskFileSystem
impl Upcast<Box<dyn ValueDebug>> for DiskFileSystem
impl Upcast<Box<dyn ValueToString>> for DiskFileSystem
impl UpcastStrict<Box<dyn FileSystem>> for DiskFileSystem
impl UpcastStrict<Box<dyn ValueDebug>> for DiskFileSystem
impl UpcastStrict<Box<dyn ValueToString>> for DiskFileSystem
Source§impl ValueDebug for DiskFileSystem
impl ValueDebug for DiskFileSystem
Source§impl ValueDebugFormat for DiskFileSystem
Available on debug-assertions enabled only.
impl ValueDebugFormat for DiskFileSystem
fn value_debug_format<'a>(&'a self, depth: usize) -> ValueDebugFormatString<'a>
Source§impl ValueToStringRef for DiskFileSystem
impl ValueToStringRef for DiskFileSystem
async fn to_string_ref(&self) -> Result<RcStr>
Source§impl VcValueType for DiskFileSystem
impl VcValueType for DiskFileSystem
Source§type Read = VcDefaultRead<DiskFileSystem>
type Read = VcDefaultRead<DiskFileSystem>
Source§type CellMode = VcCellNewMode<DiskFileSystem>
type CellMode = VcCellNewMode<DiskFileSystem>
Source§fn get_value_type_id() -> ValueTypeId
fn get_value_type_id() -> ValueTypeId
fn has_serialization() -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for DiskFileSystem
impl !UnwindSafe for DiskFileSystem
impl Freeze for DiskFileSystem
impl Send for DiskFileSystem
impl Sync for DiskFileSystem
impl Unpin for DiskFileSystem
impl UnsafeUnpin for DiskFileSystem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more