/// Given an Offer or Exposeclause, return the set of target identifiers.
///
/// When only one capability identifier is specified, the target identifier name is derived
/// using the "as" clause. If an "as" clause is not specified, the target identifier is the
/// same name as the source.
///
/// When multiple capability identifiers are specified, the target names are the same as the
/// source names.
Given an Offer or Exposeclause, return the set of target identifiers.
When only one capability identifier is specified, the target identifier name is derived
using the "as" clause. If an "as" clause is not specified, the target identifier is the
same name as the source.

When multiple capability identifiers are specified, the target names are the same as the
source names.
Given an Offer or Exposeclause return the set of target identifiers . When only one capability identifier is specified the target identifier name is derived using the " as " clause . If an " as " clause is not specified the target identifier is the same name as the source . When multiple capability identifiers are specified the target names are the same as the source names .
pub fn from_offer_expose<T>(clause: &T) -> Result<Vec<CapabilityId>, Error>
    where
        T: CapabilityClause + AsClause + FilterClause + fmt::Debug,
    {
        // TODO: Validate that exactly one of these is set.
        let alias = clause.r#as();
        if let Some(n) = clause.service() {
            return Ok(Self::services_from(Self::get_one_or_many_names(
                n,
                alias,
                clause.capability_type(),
            )?));
        } else if let Some(n) = clause.protocol() {
            return Ok(Self::protocols_from(Self::get_one_or_many_names(
                n,
                alias,
                clause.capability_type(),
            )?));
        } else if let Some(n) = clause.directory() {
            return Ok(Self::directories_from(Self::get_one_or_many_names(
                n,
                alias,
                clause.capability_type(),
            )?));
        } else if let Some(n) = clause.storage() {
            return Ok(Self::storages_from(Self::get_one_or_many_names(
                n,
                alias,
                clause.capability_type(),
            )?));
        } else if let Some(n) = clause.runner() {
            return Ok(Self::runners_from(Self::get_one_or_many_names(
                n,
                alias,
                clause.capability_type(),
            )?));
        } else if let Some(n) = clause.resolver() {
            return Ok(Self::resolvers_from(Self::get_one_or_many_names(
                n,
                alias,
                clause.capability_type(),
            )?));
        } else if let Some(events) = clause.event() {
            return match events {
                event @ OneOrMany::One(_) => Ok(Self::events_from(Self::get_one_or_many_names(
                    event,
                    alias,
                    clause.capability_type(),
                )?)),
                OneOrMany::Many(events) => match (alias, clause.filter(), events.len()) {
                    (Some(alias), _, 1) => Ok(vec![CapabilityId::Event(alias.clone())]),
                    (None, Some(_), 1) => Ok(vec![CapabilityId::Event(events[0].clone())]),
                    (Some(_), None, _) => Err(Error::validate(
                        "\"as\" can only be specified when one `event` is supplied",
                    )),
                    (None, Some(_), _) => Err(Error::validate(
                        "\"filter\" can only be specified when one `event` is supplied",
                    )),
                    (Some(_), Some(_), _) => Err(Error::validate(
                        "\"as\",\"filter\" can only be specified when one `event` is supplied",
                    )),
                    (None, None, _) => Ok(events
                        .iter()
                        .map(|event: &Name| CapabilityId::Event(event.clone()))
                        .collect()),
                },
            };
        }
        // Unsupported capability type.
        let supported_keywords = clause
            .supported()
            .into_iter()
            .map(|k| format!("\"{}\"", k))
            .collect::<Vec<_>>()
            .join(", ");
        Err(Error::validate(format!(
            "`{}` declaration is missing a capability keyword, one of: {}",
            clause.decl_type(),
            supported_keywords,
        )))
    }
pub fn from_offer_expose < T > ( clause : & T ) -> Result < Vec < CapabilityId > , Error > where T : CapabilityClause + AsClause + FilterClause + fmt :: Debug , { // TODO: Validate that exactly one of these is set. let alias = clause . r#as ( ) ; if let Some ( n ) = clause . service ( ) { return Ok ( Self :: services_from ( Self :: get_one_or_many_names ( n , alias , clause . capability_type ( ) , ) ? ) ) ; } else if let Some ( n ) = clause . protocol ( ) { return Ok ( Self :: protocols_from ( Self :: get_one_or_many_names ( n , alias , clause . capability_type ( ) , ) ? ) ) ; } else if let Some ( n ) = clause . directory ( ) { return Ok ( Self :: directories_from ( Self :: get_one_or_many_names ( n , alias , clause . capability_type ( ) , ) ? ) ) ; } else if let Some ( n ) = clause . storage ( ) { return Ok ( Self :: storages_from ( Self :: get_one_or_many_names ( n , alias , clause . capability_type ( ) , ) ? ) ) ; } else if let Some ( n ) = clause . runner ( ) { return Ok ( Self :: runners_from ( Self :: get_one_or_many_names ( n , alias , clause . capability_type ( ) , ) ? ) ) ; } else if let Some ( n ) = clause . resolver ( ) { return Ok ( Self :: resolvers_from ( Self :: get_one_or_many_names ( n , alias , clause . capability_type ( ) , ) ? ) ) ; } else if let Some ( events ) = clause . event ( ) { return match events { event @ OneOrMany :: One ( _ ) => Ok ( Self :: events_from ( Self :: get_one_or_many_names ( event , alias , clause . capability_type ( ) , ) ? ) ) , OneOrMany :: Many ( events ) => match ( alias , clause . filter ( ) , events . len ( ) ) { ( Some ( alias ) , _ , 1 ) => Ok ( vec ! [ CapabilityId Event ( alias clone ( ) ) ] ) , ( None , Some ( _ ) , 1 ) => Ok ( vec ! [ CapabilityId Event ( events [ 0 ] clone ( ) ) ] ) , ( Some ( _ ) , None , _ ) => Err ( Error :: validate ( " \" \" " , ) ) , ( None , Some ( _ ) , _ ) => Err ( Error :: validate ( " \" \" " , ) ) , ( Some ( _ ) , Some ( _ ) , _ ) => Err ( Error :: validate ( " \" \" \" \" " , ) ) , ( None , None , _ ) => Ok ( events . iter ( ) . map ( | event : & Name | CapabilityId :: Event ( event . clone ( ) ) ) . collect ( ) ) , } , } ; } // Unsupported capability type. let supported_keywords = clause . supported ( ) . into_iter ( ) . map ( | k | format ! ( " \" \" " k ) ) . collect :: < Vec < _ > > ( ) . join ( " " ) ; Err ( Error :: validate ( format ! ( " " clause decl_type ( ) supported_keywords ) ) ) }
Given an Offer or Exposeclause, return the set of target identifiers.
Given an Offer or Exposeclause return the set of target identifiers .
clause
&T