Skip to main content

DiskFileSystem

Struct DiskFileSystem 

Source
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

Source

pub fn name(&self) -> &RcStr

Source

pub fn root(&self) -> &RcStr

Source

pub fn invalidate(&self)

Source

pub fn invalidate_with_reason<R: InvalidationReason + Clone>( &self, reason: impl Fn(&Path) -> R + Sync, )

Source

pub fn invalidate_path_and_children_with_reason<R: InvalidationReason + Clone>( &self, paths: impl IntoIterator<Item = PathBuf>, reason: impl Fn(&Path) -> R + Sync, )

Source

pub async fn start_watching(&self) -> Result<()>

Source

pub async fn stop_watching(&self)

Source

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/PathBuf should not be stored in the filesystem cache, so the function cannot be a turbo_tasks::function.
  • It’s a little convenient for this function to be sync.
Source

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.

Source

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.

Source

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

Source

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.

Source

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

Source§

fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given BorrowDecode.
Source§

impl Clone for DiskFileSystem

Source§

fn clone(&self) -> DiskFileSystem

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DiskFileSystem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<__Context> Decode<__Context> for DiskFileSystem

Source§

fn decode<__D: Decoder<Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given Decode.
Source§

impl Encode for DiskFileSystem

Source§

fn encode<__E: Encoder>(&self, encoder: &mut __E) -> Result<(), EncodeError>

Encode a given type.
Source§

impl FileSystem for DiskFileSystem

Source§

fn read(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<FileContent>

Source§

fn raw_read_dir( self: Vc<Self>, fs_path: FileSystemPath, ) -> Vc<RawDirectoryContent>

Reads the target of a symbolic link (or junction point on Windows). See LinkContent.
Source§

fn is_junction_point(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<bool>

Returns whether a symbolic link is a junction point on Windows. Always false on all other platforms.
Source§

fn write( self: Vc<Self>, fs_path: FileSystemPath, content: Vc<FileContent>, ) -> Vc<()>

Creates a symbolic link. See WriteLinkContent and FileSystemPath::write_link.
Source§

fn metadata(self: Vc<Self>, fs_path: FileSystemPath) -> Vc<FileMeta>

Source§

fn root(self: Vc<Self>) -> Vc<FileSystemPath>
where Self: Sized,

Returns the path to the root of the file system.
Source§

impl NonLocalValue for DiskFileSystem

Source§

impl ShrinkToFit for DiskFileSystem

Source§

fn shrink_to_fit(&mut self)

Source§

impl Upcast<Box<dyn FileSystem>> for DiskFileSystem

Source§

impl Upcast<Box<dyn ValueDebug>> for DiskFileSystem

Source§

impl Upcast<Box<dyn ValueToString>> for DiskFileSystem

Source§

impl UpcastStrict<Box<dyn FileSystem>> for DiskFileSystem

Source§

impl UpcastStrict<Box<dyn ValueDebug>> for DiskFileSystem

Source§

impl UpcastStrict<Box<dyn ValueToString>> for DiskFileSystem

Source§

impl ValueDebug for DiskFileSystem

Source§

fn dbg_depth<'a>( &'a self, depth: usize, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'a>>

Like dbg, but with a depth limit.
§

fn dbg( &self, ) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + '_>>

Source§

impl ValueDebugFormat for DiskFileSystem

Available on debug-assertions enabled only.
Source§

fn value_debug_format<'a>(&'a self, depth: usize) -> ValueDebugFormatString<'a>

Source§

impl ValueToString for DiskFileSystem

Source§

fn to_string(self: Vc<Self>) -> Vc<RcStr>

Source§

impl ValueToStringRef for DiskFileSystem

Source§

async fn to_string_ref(&self) -> Result<RcStr>

Source§

impl VcValueType for DiskFileSystem

Source§

type Read = VcDefaultRead<DiskFileSystem>

How to read the value.
Source§

type CellMode = VcCellNewMode<DiskFileSystem>

How to update cells of this value type.
Source§

fn get_value_type_id() -> ValueTypeId

Returns the type id of the value type.
Source§

fn has_serialization() -> bool

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> MaybeSendSync for T

§

impl<T> MaybeTypeTag for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more