pub fn search_once(options: Options) -> Result<Vec<Response>, Error> {
    info!("search_once - options: {:?}", options);
    options.validate()?;
    let mut message_builder = RequestBuilder::new(protocol::METHOD_SEARCH);
    // All headers from the original 1.0 specification.
    message_builder
        .add_header(protocol::HEAD_HOST, protocol::MULTICAST_ADDRESS)
        .add_header(protocol::HEAD_MAN, protocol::HTTP_EXTENSION)
        .add_header(protocol::HEAD_MX, &format!("{}", options.max_wait_time))
        .add_header(protocol::HEAD_ST, &options.search_target.to_string());
    // Headers added by 1.1 specification
    if options.spec_version >= SpecVersion::V11 {
        message_builder.add_header(
            protocol::HEAD_USER_AGENT,
            &user_agent::make(&options.spec_version, &options.product_and_version),
        );
    }
    // Headers added by 2.0 specification
    if options.spec_version >= SpecVersion::V20 {
        match &options.control_point {
            Some(cp) => {
                message_builder.add_header(protocol::HEAD_CP_FN, &cp.friendly_name);
                if let Some(uuid) = &cp.uuid {
                    message_builder.add_header(protocol::HEAD_CP_UUID, &uuid);
                }
                if let Some(port) = cp.port {
                    message_builder.add_header(protocol::HEAD_TCP_PORT, &port.to_string());
                }
            }
            None => {
                error!("search_once - missing control point, required for UPnP/2.0");
                return Err(Error::MessageFormat(MessageErrorKind::MissingRequiredField));
            }
        }
    }
    trace!("search_once - {:?}", &message_builder);
    let raw_responses = multicast(
        &message_builder.into(),
        &protocol::MULTICAST_ADDRESS.parse().unwrap(),
        &options.into(),
    )?;

    let mut responses: Vec<Response> = Vec::new();
    for raw_response in raw_responses {
        responses.push(raw_response.try_into()?);
    }
    Ok(responses)
}
///
/// Perform a multicast search but return the results immediately as a vector, not wrapped
/// in a cache.
///
/// The search function can be configured using the [`Options`](struct.Options.html) struct,
/// although the defaults are reasonable for most clients.
///
/// # Specification
///
/// TBD
///
/// # Parameters
///
/// * `options` - protocol options such as the specification version to use and any network
/// configuration values.
///
///
Perform a multicast search but return the results immediately as a vector, not wrapped
in a cache.

The search function can be configured using the [`Options`](struct.Options.html) struct,
although the defaults are reasonable for most clients.
Perform a multicast search but return the results immediately as a vector not wrapped in a cache . The search function can be configured using the [ ` Options ` ] ( struct . Options . html ) struct although the defaults are reasonable for most clients .
pub fn search_once(options: Options) -> Result<Vec<Response>, Error> {
    info!("search_once - options: {:?}", options);
    options.validate()?;
    let mut message_builder = RequestBuilder::new(protocol::METHOD_SEARCH);
    // All headers from the original 1.0 specification.
    message_builder
        .add_header(protocol::HEAD_HOST, protocol::MULTICAST_ADDRESS)
        .add_header(protocol::HEAD_MAN, protocol::HTTP_EXTENSION)
        .add_header(protocol::HEAD_MX, &format!("{}", options.max_wait_time))
        .add_header(protocol::HEAD_ST, &options.search_target.to_string());
    // Headers added by 1.1 specification
    if options.spec_version >= SpecVersion::V11 {
        message_builder.add_header(
            protocol::HEAD_USER_AGENT,
            &user_agent::make(&options.spec_version, &options.product_and_version),
        );
    }
    // Headers added by 2.0 specification
    if options.spec_version >= SpecVersion::V20 {
        match &options.control_point {
            Some(cp) => {
                message_builder.add_header(protocol::HEAD_CP_FN, &cp.friendly_name);
                if let Some(uuid) = &cp.uuid {
                    message_builder.add_header(protocol::HEAD_CP_UUID, &uuid);
                }
                if let Some(port) = cp.port {
                    message_builder.add_header(protocol::HEAD_TCP_PORT, &port.to_string());
                }
            }
            None => {
                error!("search_once - missing control point, required for UPnP/2.0");
                return Err(Error::MessageFormat(MessageErrorKind::MissingRequiredField));
            }
        }
    }
    trace!("search_once - {:?}", &message_builder);
    let raw_responses = multicast(
        &message_builder.into(),
        &protocol::MULTICAST_ADDRESS.parse().unwrap(),
        &options.into(),
    )?;
    let mut responses: Vec<Response> = Vec::new();
    for raw_response in raw_responses {
        responses.push(raw_response.try_into()?);
    }
    Ok(responses)
}
pub fn search_once ( options : Options ) -> Result < Vec < Response > , Error > { info ! ( " " options ) ; options . validate ( ) ? ; let mut message_builder = RequestBuilder :: new ( protocol :: METHOD_SEARCH ) ; // All headers from the original 1.0 specification. message_builder . add_header ( protocol :: HEAD_HOST , protocol :: MULTICAST_ADDRESS ) . add_header ( protocol :: HEAD_MAN , protocol :: HTTP_EXTENSION ) . add_header ( protocol :: HEAD_MX , & format ! ( " " options max_wait_time ) ) . add_header ( protocol :: HEAD_ST , & options . search_target . to_string ( ) ) ; // Headers added by 1.1 specification if options . spec_version >= SpecVersion :: V11 { message_builder . add_header ( protocol :: HEAD_USER_AGENT , & user_agent :: make ( & options . spec_version , & options . product_and_version ) , ) ; } // Headers added by 2.0 specification if options . spec_version >= SpecVersion :: V20 { match & options . control_point { Some ( cp ) => { message_builder . add_header ( protocol :: HEAD_CP_FN , & cp . friendly_name ) ; if let Some ( uuid ) = & cp . uuid { message_builder . add_header ( protocol :: HEAD_CP_UUID , & uuid ) ; } if let Some ( port ) = cp . port { message_builder . add_header ( protocol :: HEAD_TCP_PORT , & port . to_string ( ) ) ; } } None => { error ! ( " " ) ; return Err ( Error :: MessageFormat ( MessageErrorKind :: MissingRequiredField ) ) ; } } } trace ! ( " " message_builder ) ; let raw_responses = multicast ( & message_builder . into ( ) , & protocol :: MULTICAST_ADDRESS . parse ( ) . unwrap ( ) , & options . into ( ) , ) ? ; let mut responses : Vec < Response > = Vec :: new ( ) ; for raw_response in raw_responses { responses . push ( raw_response . try_into ( ) ? ) ; } Ok ( responses ) }
Perform a multicast search but return the results immediately as a vector, not wrapped
in a cache.
Perform a multicast search but return the results immediately as a vector not wrapped in a cache .
options
Options
options
Options
specification
None