/// Routes a capability from `target` to its source, starting from an `expose_decl`.
///
/// If the capability is allowed to be routed to the `target`, per the
/// [`crate::model::policy::GlobalPolicyChecker`], the capability is then opened at its source
/// triggering a `CapabilityRouted` event.
///
/// See [`fidl_fuchsia_io::Directory::Open`] for how the `flags`, `open_mode`, `relative_path`,
/// and `server_chan` parameters are used in the open call.
///
/// Only capabilities that can both be opened from a VFS and be exposed to their parent
/// are supported: Protocol, Service, and Directory.
Routes a capability from `target` to its source, starting from an `expose_decl`.



Only capabilities that can both be opened from a VFS and be exposed to their parent
are supported: Protocol, Service, and Directory.
Routes a capability from ` target ` to its source starting from an ` expose_decl ` . Only capabilities that can both be opened from a VFS and be exposed to their parent are supported : Protocol Service and Directory .
pub(super) async fn route_and_open_namespace_capability_from_expose(
    flags: u32,
    open_mode: u32,
    relative_path: String,
    expose_decl: ExposeDecl,
    target: &Arc<ComponentInstance>,
    server_chan: &mut zx::Channel,
) -> Result<(), ModelError> {
    let (capability_source, relative_path) = match expose_decl {
        ExposeDecl::Service(expose_service_decl) => (
            route_service_from_expose(expose_service_decl, target).await?,
            PathBuf::from(relative_path),
        ),
        ExposeDecl::Protocol(expose_protocol_decl) => {
            (route_protocol_from_expose(expose_protocol_decl, target).await?, PathBuf::new())
        }
        ExposeDecl::Directory(expose_directory_decl) => {
            let (capability_source, directory_state) =
                route_directory_from_expose(expose_directory_decl, target).await?;
            (capability_source, directory_state.make_relative_path(relative_path))
        }
        ExposeDecl::Runner(_) | ExposeDecl::Resolver(_) => {
            return Err(ModelError::unsupported(
                "opening a capability that cannot be installed in a namespace",
            ))
        }
    };
    open_capability_at_source(
        flags,
        open_mode,
        relative_path,
        capability_source,
        target,
        server_chan,
    )
    .await
}
pub ( super ) async fn route_and_open_namespace_capability_from_expose ( flags : u32 , open_mode : u32 , relative_path : String , expose_decl : ExposeDecl , target : & Arc < ComponentInstance > , server_chan : & mut zx :: Channel , ) -> Result < ( ) , ModelError > { let ( capability_source , relative_path ) = match expose_decl { ExposeDecl :: Service ( expose_service_decl ) => ( route_service_from_expose ( expose_service_decl , target ) . await ? , PathBuf :: from ( relative_path ) , ) , ExposeDecl :: Protocol ( expose_protocol_decl ) => { ( route_protocol_from_expose ( expose_protocol_decl , target ) . await ? , PathBuf :: new ( ) ) } ExposeDecl :: Directory ( expose_directory_decl ) => { let ( capability_source , directory_state ) = route_directory_from_expose ( expose_directory_decl , target ) . await ? ; ( capability_source , directory_state . make_relative_path ( relative_path ) ) } ExposeDecl :: Runner ( _ ) | ExposeDecl :: Resolver ( _ ) => { return Err ( ModelError :: unsupported ( " " , ) ) } } ; open_capability_at_source ( flags , open_mode , relative_path , capability_source , target , server_chan , ) . await }
Routes a capability from `target` to its source, starting from an `expose_decl`.
Routes a capability from ` target ` to its source starting from an ` expose_decl ` .
flags
u32
open_mode
u32
relative_path
String
expose_decl
ExposeDecl
target
&Arc<ComponentInstance>
server_chan
&mut zx::Channel