-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added constructors to BinaryPackage and re-worked resolution so the r…
…oot package doesn't need to be in the registry
- Loading branch information
Michael-F-Bryan
committed
May 17, 2023
1 parent
2bfd39f
commit c6b70d8
Showing
11 changed files
with
195 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ use std::{ | |
use derivative::Derivative; | ||
use futures::future::BoxFuture; | ||
use virtual_net::{DynVirtualNetworking, VirtualNetworking}; | ||
use webc::Container; | ||
|
||
use crate::{ | ||
bin_factory::BinaryPackage, | ||
|
@@ -28,29 +29,6 @@ use crate::{ | |
|
||
/// Represents an implementation of the WASI runtime - by default everything is | ||
/// unimplemented. | ||
/// | ||
/// # Loading Packages | ||
/// | ||
/// Loading a package, complete with dependencies, can feel a bit involved | ||
/// because it requires several non-trivial components. | ||
/// | ||
/// ```rust | ||
/// use wasmer_wasix::{ | ||
/// runtime::{ | ||
/// WasiRuntime, | ||
/// resolver::{PackageSpecifier, resolve}, | ||
/// }, | ||
/// bin_factory::BinaryPackage, | ||
/// }; | ||
/// | ||
/// async fn with_runtime(runtime: &dyn WasiRuntime) -> Result<(), Box<dyn std::error::Error + Send +Sync>> { | ||
/// let registry = runtime.registry(); | ||
/// let specifier: PackageSpecifier = "python/[email protected]".parse()?; | ||
/// let root_package = registry.latest(&specifier).await?; | ||
/// let resolution = resolve(&root_package, ®istry).await?; | ||
/// let pkg: BinaryPackage = runtime.load_package_tree(&resolution).await?; | ||
/// Ok(()) | ||
/// } | ||
#[allow(unused_variables)] | ||
pub trait WasiRuntime | ||
where | ||
|
@@ -108,12 +86,13 @@ where | |
/// should be good enough for most applications. | ||
fn load_package_tree<'a>( | ||
&'a self, | ||
root: &'a Container, | ||
resolution: &'a Resolution, | ||
) -> BoxFuture<'a, Result<BinaryPackage, Box<dyn std::error::Error + Send + Sync>>> { | ||
let package_loader = self.package_loader(); | ||
|
||
Box::pin(async move { | ||
let pkg = package_loader::load_package_tree(&package_loader, resolution).await?; | ||
let pkg = package_loader::load_package_tree(root, &package_loader, resolution).await?; | ||
Ok(pkg) | ||
}) | ||
} | ||
|
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
Oops, something went wrong.