@@ -142,26 +142,23 @@ impl Sdk {
142142 ///
143143 /// # Errors
144144 /// Returns error if publish fails.
145- pub fn publish_to_topic_json < ' a > (
145+ pub fn publish_to_topic_json (
146146 & self ,
147- topic : impl Into < & ' a str > ,
148- payload : impl Into < Map < ' a > > ,
147+ topic : & str ,
148+ payload : & [ Kv < ' _ > ] ,
149149 ) -> Result < ( ) > {
150- fn inner ( topic : & str , payload : & Map < ' _ > ) -> Result < ( ) > {
151- let topic_buf = c:: GgBuffer {
152- data : topic. as_ptr ( ) . cast_mut ( ) ,
153- len : topic. len ( ) ,
154- } ;
155- let payload_map = c:: GgMap {
156- pairs : payload. 0 . as_ptr ( ) as * mut c:: GgKV ,
157- len : payload. 0 . len ( ) ,
158- } ;
150+ let topic_buf = c:: GgBuffer {
151+ data : topic. as_ptr ( ) . cast_mut ( ) ,
152+ len : topic. len ( ) ,
153+ } ;
154+ let payload_map = c:: GgMap {
155+ pairs : payload. as_ptr ( ) as * mut c:: GgKV ,
156+ len : payload. len ( ) ,
157+ } ;
159158
160- Result :: from ( unsafe {
161- c:: ggipc_publish_to_topic_json ( topic_buf, payload_map)
162- } )
163- }
164- inner ( topic. into ( ) , & payload. into ( ) )
159+ Result :: from ( unsafe {
160+ c:: ggipc_publish_to_topic_json ( topic_buf, payload_map)
161+ } )
165162 }
166163
167164 /// Publish a binary message to a local pub/sub topic.
@@ -186,26 +183,23 @@ impl Sdk {
186183 ///
187184 /// # Errors
188185 /// Returns error if publish fails.
189- pub fn publish_to_topic_binary < ' a > (
186+ pub fn publish_to_topic_binary (
190187 & self ,
191- topic : impl Into < & ' a str > ,
192- payload : impl AsRef < [ u8 ] > ,
188+ topic : & str ,
189+ payload : & [ u8 ] ,
193190 ) -> Result < ( ) > {
194- fn inner ( topic : & str , payload : & [ u8 ] ) -> Result < ( ) > {
195- let topic_buf = c:: GgBuffer {
196- data : topic. as_ptr ( ) . cast_mut ( ) ,
197- len : topic. len ( ) ,
198- } ;
199- let payload_buf = c:: GgBuffer {
200- data : payload. as_ptr ( ) . cast_mut ( ) ,
201- len : payload. len ( ) ,
202- } ;
191+ let topic_buf = c:: GgBuffer {
192+ data : topic. as_ptr ( ) . cast_mut ( ) ,
193+ len : topic. len ( ) ,
194+ } ;
195+ let payload_buf = c:: GgBuffer {
196+ data : payload. as_ptr ( ) . cast_mut ( ) ,
197+ len : payload. len ( ) ,
198+ } ;
203199
204- Result :: from ( unsafe {
205- c:: ggipc_publish_to_topic_binary ( topic_buf, payload_buf)
206- } )
207- }
208- inner ( topic. into ( ) , payload. as_ref ( ) )
200+ Result :: from ( unsafe {
201+ c:: ggipc_publish_to_topic_binary ( topic_buf, payload_buf)
202+ } )
209203 }
210204
211205 /// Subscribe to messages on a local pub/sub topic.
@@ -219,7 +213,7 @@ impl Sdk {
219213 /// Returns error if subscription fails.
220214 pub fn subscribe_to_topic < ' a , F : Fn ( & str , SubscribeToTopicPayload ) > (
221215 & self ,
222- topic : impl Into < & ' a str > ,
216+ topic : & str ,
223217 callback : & ' a F ,
224218 ) -> Result < Subscription < ' a , F > > {
225219 extern "C" fn trampoline < F : Fn ( & str , SubscribeToTopicPayload ) > (
@@ -254,7 +248,6 @@ impl Sdk {
254248 cb ( topic_str, unpacked) ;
255249 }
256250
257- let topic = topic. into ( ) ;
258251 let topic_buf = c:: GgBuffer {
259252 data : topic. as_ptr ( ) . cast_mut ( ) ,
260253 len : topic. len ( ) ,
@@ -301,27 +294,24 @@ impl Sdk {
301294 ///
302295 /// # Errors
303296 /// Returns error if publish fails.
304- pub fn publish_to_iot_core < ' a > (
297+ pub fn publish_to_iot_core (
305298 & self ,
306- topic : impl Into < & ' a str > ,
307- payload : impl AsRef < [ u8 ] > ,
299+ topic : & str ,
300+ payload : & [ u8 ] ,
308301 qos : Qos ,
309302 ) -> Result < ( ) > {
310- fn inner ( topic : & str , payload : & [ u8 ] , qos : Qos ) -> Result < ( ) > {
311- let topic_buf = c:: GgBuffer {
312- data : topic. as_ptr ( ) . cast_mut ( ) ,
313- len : topic. len ( ) ,
314- } ;
315- let payload_buf = c:: GgBuffer {
316- data : payload. as_ptr ( ) . cast_mut ( ) ,
317- len : payload. len ( ) ,
318- } ;
303+ let topic_buf = c:: GgBuffer {
304+ data : topic. as_ptr ( ) . cast_mut ( ) ,
305+ len : topic. len ( ) ,
306+ } ;
307+ let payload_buf = c:: GgBuffer {
308+ data : payload. as_ptr ( ) . cast_mut ( ) ,
309+ len : payload. len ( ) ,
310+ } ;
319311
320- Result :: from ( unsafe {
321- c:: ggipc_publish_to_iot_core ( topic_buf, payload_buf, qos as u8 )
322- } )
323- }
324- inner ( topic. into ( ) , payload. as_ref ( ) , qos)
312+ Result :: from ( unsafe {
313+ c:: ggipc_publish_to_iot_core ( topic_buf, payload_buf, qos as u8 )
314+ } )
325315 }
326316
327317 /// Subscribe to MQTT messages from AWS IoT Core.
@@ -335,7 +325,7 @@ impl Sdk {
335325 /// Returns error if subscription fails.
336326 pub fn subscribe_to_iot_core < ' a , F : Fn ( & str , & [ u8 ] ) > (
337327 & self ,
338- topic_filter : impl Into < & ' a str > ,
328+ topic_filter : & str ,
339329 qos : Qos ,
340330 callback : & ' a F ,
341331 ) -> Result < Subscription < ' a , F > > {
@@ -356,7 +346,6 @@ impl Sdk {
356346 cb ( topic_str, payload_bytes) ;
357347 }
358348
359- let topic_filter = topic_filter. into ( ) ;
360349 let topic_buf = c:: GgBuffer {
361350 data : topic_filter. as_ptr ( ) . cast_mut ( ) ,
362351 len : topic_filter. len ( ) ,
@@ -561,19 +550,13 @@ impl Sdk {
561550 ///
562551 /// # Errors
563552 /// Returns error if restart fails.
564- pub fn restart_component < ' a > (
565- & self ,
566- component_name : impl Into < & ' a str > ,
567- ) -> Result < ( ) > {
568- fn inner ( component_name : & str ) -> Result < ( ) > {
569- let component_buf = c:: GgBuffer {
570- data : component_name. as_ptr ( ) . cast_mut ( ) ,
571- len : component_name. len ( ) ,
572- } ;
553+ pub fn restart_component ( & self , component_name : & str ) -> Result < ( ) > {
554+ let component_buf = c:: GgBuffer {
555+ data : component_name. as_ptr ( ) . cast_mut ( ) ,
556+ len : component_name. len ( ) ,
557+ } ;
573558
574- Result :: from ( unsafe { c:: ggipc_restart_component ( component_buf) } )
575- }
576- inner ( component_name. into ( ) )
559+ Result :: from ( unsafe { c:: ggipc_restart_component ( component_buf) } )
577560 }
578561
579562 /// Subscribe to component configuration updates.
0 commit comments