Unverified Commit 89c94877 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

Turbopack: Split up turbo-tasks-fs/src/lib.rs into smaller modules (#96030)

This file was way too huge and was wasting a ton of tokens when trying
to use it with agents.

`turbo-tasks-fs/src/disk.rs` is still a little bigger than I'd like, but
I think this is an overall improvement.
parent 8882653a
This diff is collapsed.
This diff is collapsed.
//! Error helpers shared across the filesystem implementation.
use std::{error::Error as StdError, fmt};
use turbo_tasks::{NonLocalValue, trace::TraceRawVcs};
/// Wrapper to convert [`anyhow::Error`] to `impl std::error::Error` for use in [`Effect::apply`].
// TODO(bgw): use a structured error type instead of anyhow for write/write_link
#[derive(TraceRawVcs, NonLocalValue)]
pub(crate) struct AnyhowWrapper(anyhow::Error);
impl fmt::Display for AnyhowWrapper {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
impl fmt::Debug for AnyhowWrapper {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&self.0, f)
}
}
impl StdError for AnyhowWrapper {
fn source(&self) -> Option<&(dyn StdError + 'static)> {
self.0.source()
}
}
impl From<anyhow::Error> for AnyhowWrapper {
fn from(err: anyhow::Error) -> Self {
AnyhowWrapper(err)
}
}
This diff is collapsed.
//! [`NullFileSystem`], a filesystem where every path is empty/not-found.
use turbo_tasks::{ValueToString, Vc};
use crate::{FileContent, FileMeta, FileSystem, FileSystemPath, LinkContent, RawDirectoryContent};
#[derive(ValueToString)]
#[value_to_string("null")]
#[turbo_tasks::value(shared)]
pub struct NullFileSystem;
#[turbo_tasks::value_impl]
impl FileSystem for NullFileSystem {
#[turbo_tasks::function]
fn read(&self, _fs_path: FileSystemPath) -> Vc<FileContent> {
FileContent::NotFound.cell()
}
#[turbo_tasks::function]
fn read_link(&self, _fs_path: FileSystemPath) -> Vc<LinkContent> {
LinkContent::NotFound.cell()
}
#[turbo_tasks::function]
fn raw_read_dir(&self, _fs_path: FileSystemPath) -> Vc<RawDirectoryContent> {
RawDirectoryContent::not_found()
}
#[turbo_tasks::function]
fn write(&self, _fs_path: FileSystemPath, _content: Vc<FileContent>) {}
#[turbo_tasks::function]
fn write_link(&self, _fs_path: FileSystemPath, _target: Vc<LinkContent>) {}
#[turbo_tasks::function]
fn metadata(&self, _fs_path: FileSystemPath) -> Vc<FileMeta> {
FileMeta::default().cell()
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment