/// Return the name of the capability, if this is a capability declaration.
Return the name of the capability, if this is a capability declaration.
Return the name of the capability if this is a capability declaration .
pub fn source_name(&self) -> Option<&CapabilityName> {
        match self {
            ComponentCapability::Storage(storage) => Some(&storage.name),
            ComponentCapability::Protocol(protocol) => Some(&protocol.name),
            ComponentCapability::Directory(directory) => Some(&directory.name),
            ComponentCapability::Runner(runner) => Some(&runner.name),
            ComponentCapability::Resolver(resolver) => Some(&resolver.name),
            ComponentCapability::Service(service) => Some(&service.name),
            ComponentCapability::Use(use_) => match use_ {
                UseDecl::Protocol(UseProtocolDecl { source_name, .. }) => Some(source_name),
                UseDecl::Directory(UseDirectoryDecl { source_name, .. }) => Some(source_name),
                UseDecl::Event(UseEventDecl { source_name, .. }) => Some(source_name),
                UseDecl::Storage(UseStorageDecl { source_name, .. }) => Some(source_name),
                UseDecl::Service(UseServiceDecl { source_name, .. }) => Some(source_name),
                _ => None,
            },
            ComponentCapability::Environment(env_cap) => match env_cap {
                EnvironmentCapability::Runner { source_name, .. } => Some(source_name),
                EnvironmentCapability::Resolver { source_name, .. } => Some(source_name),
                EnvironmentCapability::Debug { source_name, .. } => Some(source_name),
            },
            ComponentCapability::Expose(expose) => match expose {
                ExposeDecl::Protocol(ExposeProtocolDecl { source_name, .. }) => Some(source_name),
                ExposeDecl::Directory(ExposeDirectoryDecl { source_name, .. }) => Some(source_name),
                ExposeDecl::Runner(ExposeRunnerDecl { source_name, .. }) => Some(source_name),
                ExposeDecl::Resolver(ExposeResolverDecl { source_name, .. }) => Some(source_name),
                ExposeDecl::Service(ExposeServiceDecl { sources, .. }) => {
                    // NOTE: The cm_rust transformation guarantees there is at least one source.
                    // TODO(fxbug.dev/71881): Generalize to many sources.
                    Some(&sources[0].source_name)
                }
            },
            ComponentCapability::Offer(offer) => match offer {
                OfferDecl::Protocol(OfferProtocolDecl { source_name, .. }) => Some(source_name),
                OfferDecl::Directory(OfferDirectoryDecl { source_name, .. }) => Some(source_name),
                OfferDecl::Runner(OfferRunnerDecl { source_name, .. }) => Some(source_name),
                OfferDecl::Event(OfferEventDecl { source_name, .. }) => Some(source_name),
                OfferDecl::Storage(OfferStorageDecl { source_name, .. }) => Some(source_name),
                OfferDecl::Resolver(OfferResolverDecl { source_name, .. }) => Some(source_name),
                OfferDecl::Service(OfferServiceDecl { sources, .. }) => {
                    // NOTE: The cm_rust transformation guarantees there is at least one source.
                    // TODO(fxbug.dev/71881): Generalize to many sources.
                    Some(&sources[0].source_name)
                }
            },
        }
    }
pub fn source_name ( & self ) -> Option < & CapabilityName > { match self { ComponentCapability :: Storage ( storage ) => Some ( & storage . name ) , ComponentCapability :: Protocol ( protocol ) => Some ( & protocol . name ) , ComponentCapability :: Directory ( directory ) => Some ( & directory . name ) , ComponentCapability :: Runner ( runner ) => Some ( & runner . name ) , ComponentCapability :: Resolver ( resolver ) => Some ( & resolver . name ) , ComponentCapability :: Service ( service ) => Some ( & service . name ) , ComponentCapability :: Use ( use_ ) => match use_ { UseDecl :: Protocol ( UseProtocolDecl { source_name , .. } ) => Some ( source_name ) , UseDecl :: Directory ( UseDirectoryDecl { source_name , .. } ) => Some ( source_name ) , UseDecl :: Event ( UseEventDecl { source_name , .. } ) => Some ( source_name ) , UseDecl :: Storage ( UseStorageDecl { source_name , .. } ) => Some ( source_name ) , UseDecl :: Service ( UseServiceDecl { source_name , .. } ) => Some ( source_name ) , _ => None , } , ComponentCapability :: Environment ( env_cap ) => match env_cap { EnvironmentCapability :: Runner { source_name , .. } => Some ( source_name ) , EnvironmentCapability :: Resolver { source_name , .. } => Some ( source_name ) , EnvironmentCapability :: Debug { source_name , .. } => Some ( source_name ) , } , ComponentCapability :: Expose ( expose ) => match expose { ExposeDecl :: Protocol ( ExposeProtocolDecl { source_name , .. } ) => Some ( source_name ) , ExposeDecl :: Directory ( ExposeDirectoryDecl { source_name , .. } ) => Some ( source_name ) , ExposeDecl :: Runner ( ExposeRunnerDecl { source_name , .. } ) => Some ( source_name ) , ExposeDecl :: Resolver ( ExposeResolverDecl { source_name , .. } ) => Some ( source_name ) , ExposeDecl :: Service ( ExposeServiceDecl { sources , .. } ) => { // NOTE: The cm_rust transformation guarantees there is at least one source. // TODO(fxbug.dev/71881): Generalize to many sources. Some ( & sources [ 0 ] . source_name ) } } , ComponentCapability :: Offer ( offer ) => match offer { OfferDecl :: Protocol ( OfferProtocolDecl { source_name , .. } ) => Some ( source_name ) , OfferDecl :: Directory ( OfferDirectoryDecl { source_name , .. } ) => Some ( source_name ) , OfferDecl :: Runner ( OfferRunnerDecl { source_name , .. } ) => Some ( source_name ) , OfferDecl :: Event ( OfferEventDecl { source_name , .. } ) => Some ( source_name ) , OfferDecl :: Storage ( OfferStorageDecl { source_name , .. } ) => Some ( source_name ) , OfferDecl :: Resolver ( OfferResolverDecl { source_name , .. } ) => Some ( source_name ) , OfferDecl :: Service ( OfferServiceDecl { sources , .. } ) => { // NOTE: The cm_rust transformation guarantees there is at least one source. // TODO(fxbug.dev/71881): Generalize to many sources. Some ( & sources [ 0 ] . source_name ) } } , } }
Return the name of the capability, if this is a capability declaration.
Return the name of the capability if this is a capability declaration .
&self