pub fn device_available(device: &mut Device, options: Options) -> Result<(), Error> {
    let next_boot_id = device.boot_id + 1;
    let mut message_builder = RequestBuilder::new(protocol::METHOD_NOTIFY);
    message_builder
        .add_header(protocol::HEAD_HOST, protocol::MULTICAST_ADDRESS)
        .add_header(
            protocol::HEAD_CACHE_CONTROL,
            &format!("max-age={}", options.max_age),
        )
        .add_header(protocol::HEAD_LOCATION, &device.location.to_string())
        .add_header(protocol::HEAD_NT, &device.notification_type.to_string())
        .add_header(protocol::HEAD_NTS, protocol::NTS_ALIVE)
        .add_header(
            protocol::HEAD_SERVER,
            &user_agent::make(&options.spec_version, &options.product_and_version),
        )
        .add_header(protocol::HEAD_USN, &device.service_name.to_string());

    if options.spec_version >= SpecVersion::V11 {
        message_builder
            .add_header(protocol::HEAD_BOOTID, &device.boot_id.to_string())
            .add_header(protocol::HEAD_CONFIGID, &device.config_id.to_string());
        if let Some(search_port) = &device.search_port {
            message_builder.add_header(protocol::HEAD_SEARCH_PORT, &search_port.to_string());
        }
    }

    if options.spec_version >= SpecVersion::V20 {
        if let Some(secure_location) = &device.secure_location {
            message_builder
                .add_header(protocol::HEAD_SECURE_LOCATION, &secure_location.to_string());
        }
    }

    multicast_once(
        &message_builder.into(),
        &protocol::MULTICAST_ADDRESS.parse().unwrap(),
        &options.into(),
    )?;

    device.boot_id = next_boot_id;
    Ok(())
}
/**
Provides an implementation of the `ssdp:alive` notification.

# Specification

When a device is added to the network, it multicasts discovery messages to advertise its root
device, any embedded devices, and any services. Each discovery message contains four major
components:

1. a potential search target (e.g., device type), sent in an `NT` (Notification Type) header,
2. a composite identifier for the advertisement, sent in a `USN` (Unique Service Name) header,
3. a URL for more information about the device (or enclosing device in the case of a service),
   sent in a `LOCATION` header, and
4. a duration for which the advertisement is valid, sent in a `CACHE-CONTROL` header.

# Parameters

* `device` - details of the device to publish as a part of the notification message. Not all device
     fields may be used in all notifications.
* `options` - protocol options such as the specification version to use and any network
     configuration values.

*/
Provides an implementation of the `ssdp:alive` notification.
Specification

When a device is added to the network, it multicasts discovery messages to advertise its root
device, any embedded devices, and any services. Each discovery message contains four major
components.

1. a potential search target , sent in an `NT` (Notification Type) header,
2. a composite identifier for the advertisement, sent in a `USN` (Unique Service Name) header,
3. a URL for more information about the device (or enclosing device in the case of a service),
sent in a `LOCATION` header, and
4. a duration for which the advertisement is valid, sent in a `CACHE-CONTROL` header.

Parameters

`device` - details of the device to publish as a part of the notification message. Not all device
fields may be used in all notifications.
`options` - protocol options such as the specification version to use and any network
configuration values.
Provides an implementation of the ` ssdp : alive ` notification . Specification When a device is added to the network it multicasts discovery messages to advertise its root device any embedded devices and any services . Each discovery message contains four major components . 1 . a potential search target sent in an ` NT ` ( Notification Type ) header 2 . a composite identifier for the advertisement sent in a ` USN ` ( Unique Service Name ) header 3 . a URL for more information about the device ( or enclosing device in the case of a service ) sent in a ` LOCATION ` header and 4 . a duration for which the advertisement is valid sent in a ` CACHE - CONTROL ` header . Parameters ` device ` - details of the device to publish as a part of the notification message . Not all device fields may be used in all notifications . ` options ` - protocol options such as the specification version to use and any network configuration values .
pub fn device_available(device: &mut Device, options: Options) -> Result<(), Error> {
    let next_boot_id = device.boot_id + 1;
    let mut message_builder = RequestBuilder::new(protocol::METHOD_NOTIFY);
    message_builder
        .add_header(protocol::HEAD_HOST, protocol::MULTICAST_ADDRESS)
        .add_header(
            protocol::HEAD_CACHE_CONTROL,
            &format!("max-age={}", options.max_age),
        )
        .add_header(protocol::HEAD_LOCATION, &device.location.to_string())
        .add_header(protocol::HEAD_NT, &device.notification_type.to_string())
        .add_header(protocol::HEAD_NTS, protocol::NTS_ALIVE)
        .add_header(
            protocol::HEAD_SERVER,
            &user_agent::make(&options.spec_version, &options.product_and_version),
        )
        .add_header(protocol::HEAD_USN, &device.service_name.to_string());
    if options.spec_version >= SpecVersion::V11 {
        message_builder
            .add_header(protocol::HEAD_BOOTID, &device.boot_id.to_string())
            .add_header(protocol::HEAD_CONFIGID, &device.config_id.to_string());
        if let Some(search_port) = &device.search_port {
            message_builder.add_header(protocol::HEAD_SEARCH_PORT, &search_port.to_string());
        }
    }
    if options.spec_version >= SpecVersion::V20 {
        if let Some(secure_location) = &device.secure_location {
            message_builder
                .add_header(protocol::HEAD_SECURE_LOCATION, &secure_location.to_string());
        }
    }
    multicast_once(
        &message_builder.into(),
        &protocol::MULTICAST_ADDRESS.parse().unwrap(),
        &options.into(),
    )?;
    device.boot_id = next_boot_id;
    Ok(())
}
pub fn device_available ( device : & mut Device , options : Options ) -> Result < ( ) , Error > { let next_boot_id = device . boot_id + 1 ; let mut message_builder = RequestBuilder :: new ( protocol :: METHOD_NOTIFY ) ; message_builder . add_header ( protocol :: HEAD_HOST , protocol :: MULTICAST_ADDRESS ) . add_header ( protocol :: HEAD_CACHE_CONTROL , & format ! ( " " options max_age ) , ) . add_header ( protocol :: HEAD_LOCATION , & device . location . to_string ( ) ) . add_header ( protocol :: HEAD_NT , & device . notification_type . to_string ( ) ) . add_header ( protocol :: HEAD_NTS , protocol :: NTS_ALIVE ) . add_header ( protocol :: HEAD_SERVER , & user_agent :: make ( & options . spec_version , & options . product_and_version ) , ) . add_header ( protocol :: HEAD_USN , & device . service_name . to_string ( ) ) ; if options . spec_version >= SpecVersion :: V11 { message_builder . add_header ( protocol :: HEAD_BOOTID , & device . boot_id . to_string ( ) ) . add_header ( protocol :: HEAD_CONFIGID , & device . config_id . to_string ( ) ) ; if let Some ( search_port ) = & device . search_port { message_builder . add_header ( protocol :: HEAD_SEARCH_PORT , & search_port . to_string ( ) ) ; } } if options . spec_version >= SpecVersion :: V20 { if let Some ( secure_location ) = & device . secure_location { message_builder . add_header ( protocol :: HEAD_SECURE_LOCATION , & secure_location . to_string ( ) ) ; } } multicast_once ( & message_builder . into ( ) , & protocol :: MULTICAST_ADDRESS . parse ( ) . unwrap ( ) , & options . into ( ) , ) ? ; device . boot_id = next_boot_id ; Ok ( ( ) ) }
Provides an implementation of the `ssdp:alive` notification.
Provides an implementation of the ` ssdp : alive ` notification .
device
&mut Device
options
Options
device
&mut Device
options
Options