async fn route_storage(
    use_decl: UseStorageDecl,
    target: &Arc<ComponentInstance>,
) -> Result<(storage::StorageCapabilitySource, RelativeMoniker), ModelError> {
    let allowed_sources = AllowedSourcesBuilder::new().component();
    let storage_source = RoutingStrategy::new()
        .use_::<UseStorageDecl>()
        .offer::<OfferStorageDecl>()
        .route(use_decl, target.clone(), allowed_sources, &mut StorageVisitor)
        .await?;
    target
        .try_get_context()?
        .policy()
        .can_route_capability(&storage_source, &target.abs_moniker)?;
    let (storage_decl, storage_component_instance) = match storage_source {
        CapabilitySource::Component {
            capability: ComponentCapability::Storage(storage_decl),
            component,
        } => (storage_decl, component.upgrade()?),
        _ => unreachable!("unexpected storage source"),
    };
    let relative_moniker = RelativeMoniker::from_absolute(
        &storage_component_instance.abs_moniker,
        &target.abs_moniker,
    );

    // The storage capability was routed to its source. Now route the backing directory capability.
    Ok((
        route_storage_backing_directory(storage_decl, storage_component_instance).await?,
        relative_moniker,
    ))
}
/// Routes a Storage capability from `target` to its source, starting from `use_decl`.
/// The backing Directory capability is then routed to its source.
Routes a Storage capability from `target` to its source, starting from `use_decl`.
The backing Directory capability is then routed to its source.
Routes a Storage capability from ` target ` to its source starting from ` use_decl ` . The backing Directory capability is then routed to its source .
async fn route_storage(
    use_decl: UseStorageDecl,
    target: &Arc<ComponentInstance>,
) -> Result<(storage::StorageCapabilitySource, RelativeMoniker), ModelError> {
    let allowed_sources = AllowedSourcesBuilder::new().component();
    let storage_source = RoutingStrategy::new()
        .use_::<UseStorageDecl>()
        .offer::<OfferStorageDecl>()
        .route(use_decl, target.clone(), allowed_sources, &mut StorageVisitor)
        .await?;
    target
        .try_get_context()?
        .policy()
        .can_route_capability(&storage_source, &target.abs_moniker)?;
    let (storage_decl, storage_component_instance) = match storage_source {
        CapabilitySource::Component {
            capability: ComponentCapability::Storage(storage_decl),
            component,
        } => (storage_decl, component.upgrade()?),
        _ => unreachable!("unexpected storage source"),
    };
    let relative_moniker = RelativeMoniker::from_absolute(
        &storage_component_instance.abs_moniker,
        &target.abs_moniker,
    );
    // The storage capability was routed to its source. Now route the backing directory capability.
    Ok((
        route_storage_backing_directory(storage_decl, storage_component_instance).await?,
        relative_moniker,
    ))
}
async fn route_storage ( use_decl : UseStorageDecl , target : & Arc < ComponentInstance > , ) -> Result < ( storage :: StorageCapabilitySource , RelativeMoniker ) , ModelError > { let allowed_sources = AllowedSourcesBuilder :: new ( ) . component ( ) ; let storage_source = RoutingStrategy :: new ( ) . use_ :: < UseStorageDecl > ( ) . offer :: < OfferStorageDecl > ( ) . route ( use_decl , target . clone ( ) , allowed_sources , & mut StorageVisitor ) . await ? ; target . try_get_context ( ) ? . policy ( ) . can_route_capability ( & storage_source , & target . abs_moniker ) ? ; let ( storage_decl , storage_component_instance ) = match storage_source { CapabilitySource :: Component { capability : ComponentCapability :: Storage ( storage_decl ) , component , } => ( storage_decl , component . upgrade ( ) ? ) , _ => unreachable ! ( " " ) , } ; let relative_moniker = RelativeMoniker :: from_absolute ( & storage_component_instance . abs_moniker , & target . abs_moniker , ) ; // The storage capability was routed to its source. Now route the backing directory capability. Ok ( ( route_storage_backing_directory ( storage_decl , storage_component_instance ) . await ? , relative_moniker , ) ) }
Routes a Storage capability from `target` to its source, starting from `use_decl`.
Routes a Storage capability from ` target ` to its source starting from ` use_decl ` .
use_decl
UseStorageDecl
target
&Arc<ComponentInstance>
use_decl
UseStorageDecl
target
&Arc<ComponentInstance>