1use turbo_rcstr::RcStr;
2use turbo_tasks::{ResolvedVc, TaskInput, ValueToString, Vc};
3
4use crate::{asset::Asset, ident::AssetIdent, reference::ModuleReferences};
5
6#[derive(Clone, Copy, Debug, TaskInput, Hash)]
7#[turbo_tasks::value(shared)]
8pub enum StyleType {
9 IsolatedStyle,
10 GlobalStyle,
11}
12
13#[turbo_tasks::value_trait]
16pub trait Module: Asset {
17 #[turbo_tasks::function]
20 fn ident(&self) -> Vc<AssetIdent>;
21
22 #[turbo_tasks::function]
25 fn ident_string(self: Vc<Self>) -> Vc<RcStr> {
26 self.ident().to_string()
27 }
28
29 #[turbo_tasks::function]
32 fn references(self: Vc<Self>) -> Vc<ModuleReferences> {
33 ModuleReferences::empty()
34 }
35
36 #[turbo_tasks::function]
38 fn is_self_async(self: Vc<Self>) -> Vc<bool> {
39 Vc::cell(false)
40 }
41}
42
43#[turbo_tasks::value_trait]
44pub trait StyleModule: Module + Asset {
45 #[turbo_tasks::function]
47 fn style_type(&self) -> Vc<StyleType>;
48}
49
50#[turbo_tasks::value(transparent)]
51pub struct OptionModule(Option<ResolvedVc<Box<dyn Module>>>);
52
53#[turbo_tasks::value(transparent)]
54pub struct Modules(Vec<ResolvedVc<Box<dyn Module>>>);
55
56#[turbo_tasks::value_impl]
57impl Modules {
58 #[turbo_tasks::function]
59 pub fn empty() -> Vc<Self> {
60 Vc::cell(Vec::new())
61 }
62}