/// Serve a Service directory that allows clients to list instances in a collection and to open
/// instances, triggering capability routing.
/// TODO(fxbug.dev/73153): Cache this collection directory and re-use it for requests from the
/// same target.
Serve a Service directory that allows clients to list instances in a collection and to open
instances, triggering capability routing.
TODO(fxbug.dev/73153): Cache this collection directory and re-use it for requests from the
same target.
Serve a Service directory that allows clients to list instances in a collection and to open instances triggering capability routing . TODO ( fxbug . dev / 73153 ) : Cache this collection directory and re - use it for requests from the same target .
pub async fn serve_collection<'a>(
    target: WeakComponentInstance,
    collection_component: &'a Arc<ComponentInstance>,
    provider: Box<dyn CollectionCapabilityProvider<ComponentInstance>>,
    flags: u32,
    open_mode: u32,
    path: PathBuf,
    server_chan: &'a mut Channel,
) -> Result<(), ModelError> {
    let path_utf8 = path.to_str().ok_or_else(|| ModelError::path_is_not_utf8(path.clone()))?;
    let path = vfs::path::Path::validate_and_split(path_utf8)
        .map_err(|_| ModelError::path_invalid(path_utf8))?;
    let execution_scope =
        collection_component.lock_resolved_state().await?.execution_scope().clone();
    let dir = lazy::lazy(ServiceCollectionDirectory {
        target,
        collection_component: collection_component.abs_moniker.clone(),
        provider,
    });
    dir.open(
        execution_scope,
        flags,
        open_mode,
        path,
        ServerEnd::new(channel::take_channel(server_chan)),
    );
    Ok(())
}
pub async fn serve_collection < ' a > ( target : WeakComponentInstance , collection_component : & ' a Arc < ComponentInstance > , provider : Box < dyn CollectionCapabilityProvider < ComponentInstance > > , flags : u32 , open_mode : u32 , path : PathBuf , server_chan : & ' a mut Channel , ) -> Result < ( ) , ModelError > { let path_utf8 = path . to_str ( ) . ok_or_else ( | | ModelError :: path_is_not_utf8 ( path . clone ( ) ) ) ? ; let path = vfs :: path :: Path :: validate_and_split ( path_utf8 ) . map_err ( | _ | ModelError :: path_invalid ( path_utf8 ) ) ? ; let execution_scope = collection_component . lock_resolved_state ( ) . await ? . execution_scope ( ) . clone ( ) ; let dir = lazy :: lazy ( ServiceCollectionDirectory { target , collection_component : collection_component . abs_moniker . clone ( ) , provider , } ) ; dir . open ( execution_scope , flags , open_mode , path , ServerEnd :: new ( channel :: take_channel ( server_chan ) ) , ) ; Ok ( ( ) ) }
Serve a Service directory that allows clients to list instances in a collection and to open
instances, triggering capability routing.
Serve a Service directory that allows clients to list instances in a collection and to open instances triggering capability routing .
target
WeakComponentInstance
collection_component
&'a Arc<ComponentInstance>
provider
Box<dyn CollectionCapabilityProvider<ComponentInstance>>
flags
u32
open_mode
u32
path
PathBuf
server_chan
&'a mut Channel