-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
344 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use anyhow::{Context, Result}; | ||
|
||
use crate::asset::{Asset, AssetOptionVc, AssetVc}; | ||
|
||
/// (Unparsed) Source Code. Source Code is processed into [Module]s by the | ||
/// [AssetContext]. All [Source]s have content and an identifier. | ||
#[turbo_tasks::value_trait] | ||
pub trait Source: Asset {} | ||
|
||
#[turbo_tasks::value(transparent)] | ||
pub struct OptionSource(Option<SourceVc>); | ||
|
||
#[turbo_tasks::value(transparent)] | ||
pub struct Sources(Vec<SourceVc>); | ||
|
||
/// This is a temporary function that should be removed once the [Source] trait | ||
/// completely replaces the [Asset] trait. | ||
/// TODO make this function unnecessary | ||
#[turbo_tasks::function] | ||
pub async fn asset_to_source(asset: AssetVc) -> Result<SourceVc> { | ||
Ok(SourceVc::resolve_from(asset) | ||
.await? | ||
.context("Asset must be a Source")?) | ||
} | ||
|
||
/// This is a temporary function that should be removed once the [Source] trait | ||
/// completely replaces the [Asset] trait. | ||
/// TODO make this function unnecessary | ||
#[turbo_tasks::function] | ||
pub async fn option_asset_to_source(asset: AssetOptionVc) -> Result<OptionSourceVc> { | ||
if let Some(asset) = *asset.await? { | ||
Ok(OptionSourceVc::cell(Some( | ||
SourceVc::resolve_from(asset) | ||
.await? | ||
.context("Asset must be a Source")?, | ||
))) | ||
} else { | ||
Ok(OptionSourceVc::cell(None)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.