turbopack_core/source.rs
1use turbo_tasks::{ResolvedVc, Vc};
2
3use crate::{asset::Asset, ident::AssetIdent};
4
5/// (Unparsed) Source Code. Source Code is processed into [Module]s by the
6/// [AssetContext]. All [Source]s have content and an identifier.
7#[turbo_tasks::value_trait]
8pub trait Source: Asset {
9 /// The identifier of the [Source]. It's expected to be unique and capture
10 /// all properties of the [Source].
11 fn ident(&self) -> Vc<AssetIdent>;
12}
13
14#[turbo_tasks::value(transparent)]
15pub struct OptionSource(Option<ResolvedVc<Box<dyn Source>>>);
16
17#[turbo_tasks::value(transparent)]
18pub struct Sources(Vec<ResolvedVc<Box<dyn Source>>>);
19
20// TODO All Vc::try_resolve_downcast::<Box<dyn Source>> calls should be removed