pub async fn route_storage_backing_directory(
    storage_decl: StorageDecl,
    target: Arc<ComponentInstance>,
) -> Result<storage::StorageCapabilitySource, RoutingError> {
    // Storage rights are always READ+WRITE.
    let mut state = DirectoryState::new(*READ_RIGHTS | *WRITE_RIGHTS, None);
    let allowed_sources = AllowedSourcesBuilder::new().component().namespace();
    let source = RoutingStrategy::new()
        .registration::<StorageDeclAsRegistration>()
        .offer::<OfferDirectoryDecl>()
        .expose::<ExposeDirectoryDecl>()
        .route(storage_decl.clone().into(), target, allowed_sources, &mut state)
        .await?;

    let (dir_source_path, dir_source_instance) = match source {
        CapabilitySource::Component { capability, component } => (
            capability.source_path().expect("directory has no source path?").clone(),
            Some(component.upgrade()?),
        ),
        CapabilitySource::Namespace { capability, .. } => {
            (capability.source_path().expect("directory has no source path?").clone(), None)
        }
        _ => unreachable!("not valid sources"),
    };

    let dir_subdir = if state.subdir == Path::new("") { None } else { Some(state.subdir) };

    Ok(storage::StorageCapabilitySource {
        storage_provider: dir_source_instance,
        backing_directory_path: dir_source_path,
        backing_directory_subdir: dir_subdir,
        storage_subdir: storage_decl.subdir.clone(),
    })
}
/// Routes the backing Directory capability of a Storage capability from `target` to its source,
/// starting from `storage_decl`.
Routes the backing Directory capability of a Storage capability from `target` to its source,
starting from `storage_decl`.
Routes the backing Directory capability of a Storage capability from ` target ` to its source starting from ` storage_decl ` .
pub async fn route_storage_backing_directory(
    storage_decl: StorageDecl,
    target: Arc<ComponentInstance>,
) -> Result<storage::StorageCapabilitySource, RoutingError> {
    // Storage rights are always READ+WRITE.
    let mut state = DirectoryState::new(*READ_RIGHTS | *WRITE_RIGHTS, None);
    let allowed_sources = AllowedSourcesBuilder::new().component().namespace();
    let source = RoutingStrategy::new()
        .registration::<StorageDeclAsRegistration>()
        .offer::<OfferDirectoryDecl>()
        .expose::<ExposeDirectoryDecl>()
        .route(storage_decl.clone().into(), target, allowed_sources, &mut state)
        .await?;
    let (dir_source_path, dir_source_instance) = match source {
        CapabilitySource::Component { capability, component } => (
            capability.source_path().expect("directory has no source path?").clone(),
            Some(component.upgrade()?),
        ),
        CapabilitySource::Namespace { capability, .. } => {
            (capability.source_path().expect("directory has no source path?").clone(), None)
        }
        _ => unreachable!("not valid sources"),
    };
    let dir_subdir = if state.subdir == Path::new("") { None } else { Some(state.subdir) };
    Ok(storage::StorageCapabilitySource {
        storage_provider: dir_source_instance,
        backing_directory_path: dir_source_path,
        backing_directory_subdir: dir_subdir,
        storage_subdir: storage_decl.subdir.clone(),
    })
}
pub async fn route_storage_backing_directory ( storage_decl : StorageDecl , target : Arc < ComponentInstance > , ) -> Result < storage :: StorageCapabilitySource , RoutingError > { // Storage rights are always READ+WRITE. let mut state = DirectoryState :: new ( * READ_RIGHTS | * WRITE_RIGHTS , None ) ; let allowed_sources = AllowedSourcesBuilder :: new ( ) . component ( ) . namespace ( ) ; let source = RoutingStrategy :: new ( ) . registration :: < StorageDeclAsRegistration > ( ) . offer :: < OfferDirectoryDecl > ( ) . expose :: < ExposeDirectoryDecl > ( ) . route ( storage_decl . clone ( ) . into ( ) , target , allowed_sources , & mut state ) . await ? ; let ( dir_source_path , dir_source_instance ) = match source { CapabilitySource :: Component { capability , component } => ( capability . source_path ( ) . expect ( " " ) . clone ( ) , Some ( component . upgrade ( ) ? ) , ) , CapabilitySource :: Namespace { capability , .. } => { ( capability . source_path ( ) . expect ( " " ) . clone ( ) , None ) } _ => unreachable ! ( " " ) , } ; let dir_subdir = if state . subdir == Path :: new ( " " ) { None } else { Some ( state . subdir ) } ; Ok ( storage :: StorageCapabilitySource { storage_provider : dir_source_instance , backing_directory_path : dir_source_path , backing_directory_subdir : dir_subdir , storage_subdir : storage_decl . subdir . clone ( ) , } ) }
Routes the backing Directory capability of a Storage capability from `target` to its source,
starting from `storage_decl`.
Routes the backing Directory capability of a Storage capability from ` target ` to its source starting from ` storage_decl ` .
storage_decl
StorageDecl
target
Arc<ComponentInstance>
storage_decl
StorageDecl
target
Arc<ComponentInstance>