fn republish(&mut self) -> Result<(), ()> {
        let MinireqContext {
            mqtt,
            handlers,
            prefix,
            ..
        } = self;

        for (command_prefix, HandlerMeta { republished, .. }) in handlers
            .iter_mut()
            .filter(|(_, HandlerMeta { republished, .. })| !republished)
        {
            // Note(unwrap): The unwrap cannot fail because of restrictions on the max topic
            // length.
            let mut topic: String<{ 2 * MAX_TOPIC_LENGTH + 1 }> = String::from(prefix.as_str());
            topic.push_str("/").unwrap();
            topic.push_str(command_prefix).unwrap();

            mqtt.client
                .publish(
                    &topic,
                    // Empty payload would correspond to deleting a retained message.
                    "{}".as_bytes(),
                    // TODO: When Minimq supports more QoS levels, this should be increased to
                    // ensure that the client has received it at least once.
                    QoS::AtMostOnce,
                    Retain::Retained,
                    &[REPUBLISH_CORRELATION_DATA],
                )
                .map_err(|_| ())?;

            *republished = true;
        }

        Ok(())
    }
/// Guard to handle republishing all of the command information.
///
/// # Returns
/// Ok if all command information has been republished. Error if there are still more to be
/// published.
Guard to handle republishing all of the command information.
Guard to handle republishing all of the command information .
fn republish(&mut self) -> Result<(), ()> {
        let MinireqContext {
            mqtt,
            handlers,
            prefix,
            ..
        } = self;
        for (command_prefix, HandlerMeta { republished, .. }) in handlers
            .iter_mut()
            .filter(|(_, HandlerMeta { republished, .. })| !republished)
        {
            // Note(unwrap): The unwrap cannot fail because of restrictions on the max topic
            // length.
            let mut topic: String<{ 2 * MAX_TOPIC_LENGTH + 1 }> = String::from(prefix.as_str());
            topic.push_str("/").unwrap();
            topic.push_str(command_prefix).unwrap();
            mqtt.client
                .publish(
                    &topic,
                    // Empty payload would correspond to deleting a retained message.
                    "{}".as_bytes(),
                    // TODO: When Minimq supports more QoS levels, this should be increased to
                    // ensure that the client has received it at least once.
                    QoS::AtMostOnce,
                    Retain::Retained,
                    &[REPUBLISH_CORRELATION_DATA],
                )
                .map_err(|_| ())?;
            *republished = true;
        }
        Ok(())
    }
fn republish ( & mut self ) -> Result < ( ) , ( ) > { let MinireqContext { mqtt , handlers , prefix , .. } = self ; for ( command_prefix , HandlerMeta { republished , .. } ) in handlers . iter_mut ( ) . filter ( | ( _ , HandlerMeta { republished , .. } ) | ! republished ) { // Note(unwrap): The unwrap cannot fail because of restrictions on the max topic // length. let mut topic : String < { 2 * MAX_TOPIC_LENGTH + 1 } > = String :: from ( prefix . as_str ( ) ) ; topic . push_str ( " " ) . unwrap ( ) ; topic . push_str ( command_prefix ) . unwrap ( ) ; mqtt . client . publish ( & topic , // Empty payload would correspond to deleting a retained message. " " . as_bytes ( ) , // TODO: When Minimq supports more QoS levels, this should be increased to // ensure that the client has received it at least once. QoS :: AtMostOnce , Retain :: Retained , & [ REPUBLISH_CORRELATION_DATA ] , ) . map_err ( | _ | ( ) ) ? ; * republished = true ; } Ok ( ( ) ) }
Guard to handle republishing all of the command information.
Guard to handle republishing all of the command information .
&mut self
Ok if all command information has been republished. Error if there are still more to be
published.
Ok if all command information has been republished . Error if there are still more to be published .
&mut self