1use anyhow::Result;
2use turbo_tasks::{FxIndexSet, ResolvedVc, Vc};
3use turbo_tasks_fs::FileSystemPath;
4
5use crate::asset::Asset;
6
7#[turbo_tasks::value(transparent)]
8pub struct OptionOutputAsset(Option<ResolvedVc<Box<dyn OutputAsset>>>);
9
10#[turbo_tasks::value_trait]
13pub trait OutputAsset: Asset {
14 #[turbo_tasks::function]
17 fn path(&self) -> Vc<FileSystemPath>;
18
19 #[turbo_tasks::function]
21 fn references(self: Vc<Self>) -> Vc<OutputAssets> {
22 OutputAssets::empty()
23 }
24
25 #[turbo_tasks::function]
26 fn size_bytes(self: Vc<Self>) -> Vc<Option<u64>> {
27 Vc::cell(None)
28 }
29}
30
31#[turbo_tasks::value(transparent)]
32pub struct OutputAssets(Vec<ResolvedVc<Box<dyn OutputAsset>>>);
33
34#[turbo_tasks::value_impl]
35impl OutputAssets {
36 #[turbo_tasks::function]
37 pub fn new(assets: Vec<ResolvedVc<Box<dyn OutputAsset>>>) -> Vc<Self> {
38 Vc::cell(assets)
39 }
40
41 #[turbo_tasks::function]
42 pub async fn concatenate(&self, other: Vc<Self>) -> Result<Vc<Self>> {
43 let mut assets: FxIndexSet<_> = self.0.iter().copied().collect();
44 assets.extend(other.await?.iter().copied());
45 Ok(Vc::cell(assets.into_iter().collect()))
46 }
47}
48
49impl OutputAssets {
50 pub fn empty() -> Vc<Self> {
51 Self::new(vec![])
52 }
53
54 pub fn empty_resolved() -> ResolvedVc<Self> {
55 ResolvedVc::cell(vec![])
56 }
57}
58
59#[turbo_tasks::value(transparent)]
61pub struct OutputAssetsSet(FxIndexSet<ResolvedVc<Box<dyn OutputAsset>>>);
62
63