pub fn from_use(use_: &Use) -> Result<Vec<CapabilityId>, Error> {
        // TODO: Validate that exactly one of these is set.
        let alias = use_.path.as_ref();
        if let Some(n) = use_.service() {
            return Ok(Self::used_services_from(Self::get_one_or_many_svc_paths(
                n,
                alias,
                use_.capability_type(),
            )?));
        } else if let Some(n) = use_.protocol() {
            return Ok(Self::used_protocols_from(Self::get_one_or_many_svc_paths(
                n,
                alias,
                use_.capability_type(),
            )?));
        } else if let Some(_) = use_.directory.as_ref() {
            if use_.path.is_none() {
                return Err(Error::validate("\"path\" should be present for `use directory`."));
            }
            return Ok(vec![CapabilityId::UsedDirectory(use_.path.as_ref().unwrap().clone())]);
        } else if let Some(_) = use_.storage.as_ref() {
            if use_.path.is_none() {
                return Err(Error::validate("\"path\" should be present for `use storage`."));
            }
            return Ok(vec![CapabilityId::UsedStorage(use_.path.as_ref().unwrap().clone())]);
        } else if let Some(OneOrMany::One(n)) = use_.event.as_ref() {
            return Ok(vec![CapabilityId::Event(alias_or_name(use_.r#as.as_ref(), n))]);
        } else if let Some(OneOrMany::Many(events)) = use_.event.as_ref() {
            return match (use_.r#as.as_ref(), use_.filter.as_ref(), 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()),
            };
        } else if let Some(name) = use_.event_stream_deprecated() {
            return Ok(vec![CapabilityId::EventStreamDeprecated(name)]);
        } else if let Some(_) = use_.event_stream() {
            if let Some(path) = use_.path() {
                return Ok(vec![CapabilityId::EventStream(path.clone())]);
            }
            return Ok(vec![CapabilityId::EventStream(Path::new(
                "/svc/fuchsia.component.EventStream".to_string(),
            )?)]);
        }
        // Unsupported capability type.
        let supported_keywords = use_
            .supported()
            .into_iter()
            .map(|k| format!("\"{}\"", k))
            .collect::<Vec<_>>()
            .join(", ");
        Err(Error::validate(format!(
            "`{}` declaration is missing a capability keyword, one of: {}",
            use_.decl_type(),
            supported_keywords,
        )))
    }
/// Given a Use clause, return the set of target identifiers.
///
/// When only one capability identifier is specified, the target identifier name is derived
/// using the "path" clause. If a "path" 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 a Use clause, return the set of target identifiers.
When only one capability identifier is specified, the target identifier name is derived
using the "path" clause. If a "path" 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 a Use clause return the set of target identifiers . When only one capability identifier is specified the target identifier name is derived using the " path " clause . If a " path " 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_use(use_: &Use) -> Result<Vec<CapabilityId>, Error> {
        // TODO: Validate that exactly one of these is set.
        let alias = use_.path.as_ref();
        if let Some(n) = use_.service() {
            return Ok(Self::used_services_from(Self::get_one_or_many_svc_paths(
                n,
                alias,
                use_.capability_type(),
            )?));
        } else if let Some(n) = use_.protocol() {
            return Ok(Self::used_protocols_from(Self::get_one_or_many_svc_paths(
                n,
                alias,
                use_.capability_type(),
            )?));
        } else if let Some(_) = use_.directory.as_ref() {
            if use_.path.is_none() {
                return Err(Error::validate("\"path\" should be present for `use directory`."));
            }
            return Ok(vec![CapabilityId::UsedDirectory(use_.path.as_ref().unwrap().clone())]);
        } else if let Some(_) = use_.storage.as_ref() {
            if use_.path.is_none() {
                return Err(Error::validate("\"path\" should be present for `use storage`."));
            }
            return Ok(vec![CapabilityId::UsedStorage(use_.path.as_ref().unwrap().clone())]);
        } else if let Some(OneOrMany::One(n)) = use_.event.as_ref() {
            return Ok(vec![CapabilityId::Event(alias_or_name(use_.r#as.as_ref(), n))]);
        } else if let Some(OneOrMany::Many(events)) = use_.event.as_ref() {
            return match (use_.r#as.as_ref(), use_.filter.as_ref(), 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()),
            };
        } else if let Some(name) = use_.event_stream_deprecated() {
            return Ok(vec![CapabilityId::EventStreamDeprecated(name)]);
        } else if let Some(_) = use_.event_stream() {
            if let Some(path) = use_.path() {
                return Ok(vec![CapabilityId::EventStream(path.clone())]);
            }
            return Ok(vec![CapabilityId::EventStream(Path::new(
                "/svc/fuchsia.component.EventStream".to_string(),
            )?)]);
        }
        // Unsupported capability type.
        let supported_keywords = use_
            .supported()
            .into_iter()
            .map(|k| format!("\"{}\"", k))
            .collect::<Vec<_>>()
            .join(", ");
        Err(Error::validate(format!(
            "`{}` declaration is missing a capability keyword, one of: {}",
            use_.decl_type(),
            supported_keywords,
        )))
    }
pub fn from_use ( use_ : & Use ) -> Result < Vec < CapabilityId > , Error > { // TODO: Validate that exactly one of these is set. let alias = use_ . path . as_ref ( ) ; if let Some ( n ) = use_ . service ( ) { return Ok ( Self :: used_services_from ( Self :: get_one_or_many_svc_paths ( n , alias , use_ . capability_type ( ) , ) ? ) ) ; } else if let Some ( n ) = use_ . protocol ( ) { return Ok ( Self :: used_protocols_from ( Self :: get_one_or_many_svc_paths ( n , alias , use_ . capability_type ( ) , ) ? ) ) ; } else if let Some ( _ ) = use_ . directory . as_ref ( ) { if use_ . path . is_none ( ) { return Err ( Error :: validate ( " \" \" " ) ) ; } return Ok ( vec ! [ CapabilityId UsedDirectory ( use_ path as_ref ( ) unwrap ( ) clone ( ) ) ] ) ; } else if let Some ( _ ) = use_ . storage . as_ref ( ) { if use_ . path . is_none ( ) { return Err ( Error :: validate ( " \" \" " ) ) ; } return Ok ( vec ! [ CapabilityId UsedStorage ( use_ path as_ref ( ) unwrap ( ) clone ( ) ) ] ) ; } else if let Some ( OneOrMany :: One ( n ) ) = use_ . event . as_ref ( ) { return Ok ( vec ! [ CapabilityId Event ( alias_or_name ( use_ r#as as_ref ( ) n ) ) ] ) ; } else if let Some ( OneOrMany :: Many ( events ) ) = use_ . event . as_ref ( ) { return match ( use_ . r#as . as_ref ( ) , use_ . filter . as_ref ( ) , 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 ( ) ) , } ; } else if let Some ( name ) = use_ . event_stream_deprecated ( ) { return Ok ( vec ! [ CapabilityId EventStreamDeprecated ( name ) ] ) ; } else if let Some ( _ ) = use_ . event_stream ( ) { if let Some ( path ) = use_ . path ( ) { return Ok ( vec ! [ CapabilityId EventStream ( path clone ( ) ) ] ) ; } return Ok ( vec ! [ CapabilityId EventStream ( Path new ( " " to_string ( ) ) ) ] ) ; } // Unsupported capability type. let supported_keywords = use_ . supported ( ) . into_iter ( ) . map ( | k | format ! ( " \" \" " k ) ) . collect :: < Vec < _ > > ( ) . join ( " " ) ; Err ( Error :: validate ( format ! ( " " use_ decl_type ( ) supported_keywords ) ) ) }
Given a Use clause, return the set of target identifiers.
Given a Use clause return the set of target identifiers .
use_
&Use
use_
&Use