pub(crate) fn to_service(self, id: u64, accessory_id: u64) -> Result<AccessoryInformationService> {
        let mut i = AccessoryInformationService::new(id, accessory_id);

        executor::block_on(i.identify.set_value(serde_json::Value::Bool(false)))?;
        executor::block_on(i.manufacturer.set_value(serde_json::Value::String(self.manufacturer)))?;
        executor::block_on(i.model.set_value(serde_json::Value::String(self.model)))?;
        executor::block_on(i.name.set_value(serde_json::Value::String(self.name)))?;
        executor::block_on(i.serial_number.set_value(serde_json::Value::String(self.serial_number)))?;

        if let Some(v) = self.accessory_flags {
            let mut c = AccessoryFlagsCharacteristic::new(id + 6, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.accessory_flags = Some(c);
        } else {
            i.accessory_flags = None;
        }

        if let Some(v) = self.application_matching_identifier {
            let mut c = ApplicationMatchingIdentifierCharacteristic::new(id + 7, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.application_matching_identifier = Some(c);
        } else {
            i.application_matching_identifier = None;
        }

        if let Some(v) = self.configured_name {
            let mut c = ConfiguredNameCharacteristic::new(id + 8, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.configured_name = Some(c);
        } else {
            i.configured_name = None;
        }

        if let Some(v) = self.firmware_revision {
            let mut c = FirmwareRevisionCharacteristic::new(id + 9, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.firmware_revision = Some(c);
        } else {
            i.firmware_revision = None;
        }

        if let Some(v) = self.hardware_revision {
            let mut c = HardwareRevisionCharacteristic::new(id + 10, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.hardware_revision = Some(c);
        } else {
            i.hardware_revision = None;
        }

        if let Some(v) = self.software_revision {
            let mut c = SoftwareRevisionCharacteristic::new(id + 11, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.software_revision = Some(c);
        } else {
            i.software_revision = None;
        }

        if let Some(v) = self.product_data {
            let mut c = ProductDataCharacteristic::new(id + 12, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.product_data = Some(c);
        } else {
            i.product_data = None;
        }

        Ok(i)
    }
/// Converts the `Information` struct to an Accessory Information Service.
Converts the `Information` struct to an Accessory Information Service.
Converts the ` Information ` struct to an Accessory Information Service .
pub(crate) fn to_service(self, id: u64, accessory_id: u64) -> Result<AccessoryInformationService> {
        let mut i = AccessoryInformationService::new(id, accessory_id);
        executor::block_on(i.identify.set_value(serde_json::Value::Bool(false)))?;
        executor::block_on(i.manufacturer.set_value(serde_json::Value::String(self.manufacturer)))?;
        executor::block_on(i.model.set_value(serde_json::Value::String(self.model)))?;
        executor::block_on(i.name.set_value(serde_json::Value::String(self.name)))?;
        executor::block_on(i.serial_number.set_value(serde_json::Value::String(self.serial_number)))?;
        if let Some(v) = self.accessory_flags {
            let mut c = AccessoryFlagsCharacteristic::new(id + 6, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.accessory_flags = Some(c);
        } else {
            i.accessory_flags = None;
        }
        if let Some(v) = self.application_matching_identifier {
            let mut c = ApplicationMatchingIdentifierCharacteristic::new(id + 7, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.application_matching_identifier = Some(c);
        } else {
            i.application_matching_identifier = None;
        }
        if let Some(v) = self.configured_name {
            let mut c = ConfiguredNameCharacteristic::new(id + 8, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.configured_name = Some(c);
        } else {
            i.configured_name = None;
        }
        if let Some(v) = self.firmware_revision {
            let mut c = FirmwareRevisionCharacteristic::new(id + 9, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.firmware_revision = Some(c);
        } else {
            i.firmware_revision = None;
        }
        if let Some(v) = self.hardware_revision {
            let mut c = HardwareRevisionCharacteristic::new(id + 10, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.hardware_revision = Some(c);
        } else {
            i.hardware_revision = None;
        }
        if let Some(v) = self.software_revision {
            let mut c = SoftwareRevisionCharacteristic::new(id + 11, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.software_revision = Some(c);
        } else {
            i.software_revision = None;
        }
        if let Some(v) = self.product_data {
            let mut c = ProductDataCharacteristic::new(id + 12, accessory_id);
            executor::block_on(c.set_value(v.into()))?;
            i.product_data = Some(c);
        } else {
            i.product_data = None;
        }
        Ok(i)
    }
pub ( crate ) fn to_service ( self , id : u64 , accessory_id : u64 ) -> Result < AccessoryInformationService > { let mut i = AccessoryInformationService :: new ( id , accessory_id ) ; executor :: block_on ( i . identify . set_value ( serde_json :: Value :: Bool ( false ) ) ) ? ; executor :: block_on ( i . manufacturer . set_value ( serde_json :: Value :: String ( self . manufacturer ) ) ) ? ; executor :: block_on ( i . model . set_value ( serde_json :: Value :: String ( self . model ) ) ) ? ; executor :: block_on ( i . name . set_value ( serde_json :: Value :: String ( self . name ) ) ) ? ; executor :: block_on ( i . serial_number . set_value ( serde_json :: Value :: String ( self . serial_number ) ) ) ? ; if let Some ( v ) = self . accessory_flags { let mut c = AccessoryFlagsCharacteristic :: new ( id + 6 , accessory_id ) ; executor :: block_on ( c . set_value ( v . into ( ) ) ) ? ; i . accessory_flags = Some ( c ) ; } else { i . accessory_flags = None ; } if let Some ( v ) = self . application_matching_identifier { let mut c = ApplicationMatchingIdentifierCharacteristic :: new ( id + 7 , accessory_id ) ; executor :: block_on ( c . set_value ( v . into ( ) ) ) ? ; i . application_matching_identifier = Some ( c ) ; } else { i . application_matching_identifier = None ; } if let Some ( v ) = self . configured_name { let mut c = ConfiguredNameCharacteristic :: new ( id + 8 , accessory_id ) ; executor :: block_on ( c . set_value ( v . into ( ) ) ) ? ; i . configured_name = Some ( c ) ; } else { i . configured_name = None ; } if let Some ( v ) = self . firmware_revision { let mut c = FirmwareRevisionCharacteristic :: new ( id + 9 , accessory_id ) ; executor :: block_on ( c . set_value ( v . into ( ) ) ) ? ; i . firmware_revision = Some ( c ) ; } else { i . firmware_revision = None ; } if let Some ( v ) = self . hardware_revision { let mut c = HardwareRevisionCharacteristic :: new ( id + 10 , accessory_id ) ; executor :: block_on ( c . set_value ( v . into ( ) ) ) ? ; i . hardware_revision = Some ( c ) ; } else { i . hardware_revision = None ; } if let Some ( v ) = self . software_revision { let mut c = SoftwareRevisionCharacteristic :: new ( id + 11 , accessory_id ) ; executor :: block_on ( c . set_value ( v . into ( ) ) ) ? ; i . software_revision = Some ( c ) ; } else { i . software_revision = None ; } if let Some ( v ) = self . product_data { let mut c = ProductDataCharacteristic :: new ( id + 12 , accessory_id ) ; executor :: block_on ( c . set_value ( v . into ( ) ) ) ? ; i . product_data = Some ( c ) ; } else { i . product_data = None ; } Ok ( i ) }
Converts the `Information` struct to an Accessory Information Service.
Converts the ` Information ` struct to an Accessory Information Service .
self
id
u64
accessory_id
u64
self
id
u64
accessory_id
u64