spin_compose

Function compose

Source
pub async fn compose<'a, L: ComponentSourceLoader>(
    loader: &'a L,
    component: &LockedComponent,
) -> Result<Vec<u8>, ComposeError>
Expand description

Composes a Spin AppComponent using the dependencies specified in the component’s dependencies section.

To compose the dependent component with its dependencies, the composer will first prepare the dependencies by maximally matching depenedency names to import names and register dependency components with the composition graph with the deny-all adapter applied if the set of configurations to inherit is the empty set. Once this mapping of import names to dependency infos is constructed the composer will build the instantiation arguments for the dependent component by ensuring that the export type of the dependency is a subtype of the import type of the dependent component. If the dependency has an export name specified, the composer will use that export name to satisfy the import. If the dependency does not have an export name specified, the composer will use an export of import name to satisfy the import. The composer will then alias the export of the dependency to the import of the dependent component. Finally, the composer will export all exports from the dependent component to its dependents. The composer will then encode the composition graph into a byte array and return it.