Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,12 @@ impl<D, C: Clone> CompositionGraph<D, C> {
.instantiate(&mut store, &component)
.context(instantiate_package_error::ComponentInstantiationSnafu)?;

self.shadow_package(
self.shadow_package::<SyncInstanceShadower>(
package,
Rc::new(shadow_instance),
linker,
store,
interfaces,
SyncInstanceShadower,
)
}

Expand All @@ -447,24 +446,22 @@ impl<D, C: Clone> CompositionGraph<D, C> {
.await
.context(instantiate_package_error::ComponentInstantiationSnafu)?;

self.shadow_package(
self.shadow_package::<AsyncInstanceShadower>(
package,
Rc::new(shadow_instance),
linker,
store,
interfaces,
AsyncInstanceShadower,
)
}

fn shadow_package(
fn shadow_package<T: InstanceShadower<D, C>>(
&self,
package: &Package,
shadow_instance: Rc<Instance>,
linker: &mut component::Linker<D>,
mut store: impl AsContextMut<Data = D>,
interfaces: &IndexSet<String>,
shadower: impl InstanceShadower<D, C>,
) -> Result<(), InstantiatePackageError> {
for interface_name in interfaces {
let interface_path = ForeignInterfacePath::new(
Expand Down Expand Up @@ -515,7 +512,7 @@ impl<D, C: Clone> CompositionGraph<D, C> {
func_name: export_name.to_string(),
})?;

shadower.shadow_func(
T::shadow_func(
&mut front_instance,
export_name,
shadow_func,
Expand Down Expand Up @@ -564,7 +561,6 @@ impl Deref for PackageWrapper {

trait InstanceShadower<D, C: Clone> {
fn shadow_func(
&self,
instance: &mut LinkerInstance<D>,
export_name: &str,
shadow_func: component::Func,
Expand All @@ -579,7 +575,6 @@ struct SyncInstanceShadower;

impl<D: 'static, C: Clone + Send + Sync + 'static> InstanceShadower<D, C> for SyncInstanceShadower {
fn shadow_func(
&self,
instance: &mut LinkerInstance<D>,
export_name: &str,
shadow_func: component::Func,
Expand Down Expand Up @@ -628,7 +623,6 @@ impl<D: Send + 'static, C: Clone + Send + Sync + 'static> InstanceShadower<D, C>
for AsyncInstanceShadower
{
fn shadow_func(
&self,
instance: &mut LinkerInstance<D>,
export_name: &str,
shadow_func: component::Func,
Expand Down
Loading