@@ -122,8 +122,8 @@ impl HomeserverConnection for SynapseConnection {
122122 ) ]
123123 async fn provision_user ( & self , request : & ProvisionRequest ) -> Result < bool , anyhow:: Error > {
124124 #[ derive( Serialize ) ]
125- struct Request {
126- localpart : String ,
125+ struct Request < ' a > {
126+ localpart : & ' a str ,
127127 #[ serde( skip_serializing_if = "Option::is_none" ) ]
128128 set_displayname : Option < String > ,
129129 #[ serde( skip_serializing_if = "std::ops::Not::not" ) ]
@@ -139,7 +139,7 @@ impl HomeserverConnection for SynapseConnection {
139139 }
140140
141141 let mut body = Request {
142- localpart : request. localpart ( ) . to_owned ( ) ,
142+ localpart : request. localpart ( ) ,
143143 set_displayname : None ,
144144 unset_displayname : false ,
145145 set_avatar_url : None ,
@@ -243,17 +243,17 @@ impl HomeserverConnection for SynapseConnection {
243243 initial_display_name : Option < & str > ,
244244 ) -> Result < ( ) , anyhow:: Error > {
245245 #[ derive( Serialize ) ]
246- struct Request {
247- localpart : String ,
248- device_id : String ,
246+ struct Request < ' a > {
247+ localpart : & ' a str ,
248+ device_id : & ' a str ,
249249 #[ serde( skip_serializing_if = "Option::is_none" ) ]
250- display_name : Option < String > ,
250+ display_name : Option < & ' a str > ,
251251 }
252252
253253 let body = Request {
254- localpart : localpart . to_owned ( ) ,
255- device_id : device_id . to_owned ( ) ,
256- display_name : initial_display_name. map ( ToOwned :: to_owned ) ,
254+ localpart,
255+ device_id,
256+ display_name : initial_display_name,
257257 } ;
258258
259259 let response = self
@@ -288,16 +288,16 @@ impl HomeserverConnection for SynapseConnection {
288288 display_name : & str ,
289289 ) -> Result < ( ) , anyhow:: Error > {
290290 #[ derive( Serialize ) ]
291- struct Request {
292- localpart : String ,
293- device_id : String ,
294- display_name : String ,
291+ struct Request < ' a > {
292+ localpart : & ' a str ,
293+ device_id : & ' a str ,
294+ display_name : & ' a str ,
295295 }
296296
297297 let body = Request {
298- localpart : localpart . to_owned ( ) ,
299- device_id : device_id . to_owned ( ) ,
300- display_name : display_name . to_owned ( ) ,
298+ localpart,
299+ device_id,
300+ display_name,
301301 } ;
302302
303303 let response = self
@@ -327,14 +327,14 @@ impl HomeserverConnection for SynapseConnection {
327327 ) ]
328328 async fn delete_device ( & self , localpart : & str , device_id : & str ) -> Result < ( ) , anyhow:: Error > {
329329 #[ derive( Serialize ) ]
330- struct Request {
331- localpart : String ,
332- device_id : String ,
330+ struct Request < ' a > {
331+ localpart : & ' a str ,
332+ device_id : & ' a str ,
333333 }
334334
335335 let body = Request {
336- localpart : localpart . to_owned ( ) ,
337- device_id : device_id . to_owned ( ) ,
336+ localpart,
337+ device_id,
338338 } ;
339339
340340 let response = self
@@ -368,15 +368,12 @@ impl HomeserverConnection for SynapseConnection {
368368 devices : HashSet < String > ,
369369 ) -> Result < ( ) , anyhow:: Error > {
370370 #[ derive( Serialize ) ]
371- struct Request {
372- localpart : String ,
373- devices : Vec < String > ,
371+ struct Request < ' a > {
372+ localpart : & ' a str ,
373+ devices : HashSet < String > ,
374374 }
375375
376- let body = Request {
377- localpart : localpart. to_owned ( ) ,
378- devices : devices. into_iter ( ) . collect ( ) ,
379- } ;
376+ let body = Request { localpart, devices } ;
380377
381378 let response = self
382379 . post ( "_synapse/mas/sync_devices" )
@@ -405,15 +402,12 @@ impl HomeserverConnection for SynapseConnection {
405402 ) ]
406403 async fn delete_user ( & self , localpart : & str , erase : bool ) -> Result < ( ) , anyhow:: Error > {
407404 #[ derive( Serialize ) ]
408- struct Request {
409- localpart : String ,
405+ struct Request < ' a > {
406+ localpart : & ' a str ,
410407 erase : bool ,
411408 }
412409
413- let body = Request {
414- localpart : localpart. to_owned ( ) ,
415- erase,
416- } ;
410+ let body = Request { localpart, erase } ;
417411
418412 let response = self
419413 . post ( "_synapse/mas/delete_user" )
@@ -441,13 +435,11 @@ impl HomeserverConnection for SynapseConnection {
441435 ) ]
442436 async fn reactivate_user ( & self , localpart : & str ) -> Result < ( ) , anyhow:: Error > {
443437 #[ derive( Serialize ) ]
444- struct Request {
445- localpart : String ,
438+ struct Request < ' a > {
439+ localpart : & ' a str ,
446440 }
447441
448- let body = Request {
449- localpart : localpart. to_owned ( ) ,
450- } ;
442+ let body = Request { localpart } ;
451443
452444 let response = self
453445 . post ( "_synapse/mas/reactivate_user" )
@@ -479,14 +471,14 @@ impl HomeserverConnection for SynapseConnection {
479471 displayname : & str ,
480472 ) -> Result < ( ) , anyhow:: Error > {
481473 #[ derive( Serialize ) ]
482- struct Request {
483- localpart : String ,
484- displayname : String ,
474+ struct Request < ' a > {
475+ localpart : & ' a str ,
476+ displayname : & ' a str ,
485477 }
486478
487479 let body = Request {
488- localpart : localpart . to_owned ( ) ,
489- displayname : displayname . to_owned ( ) ,
480+ localpart,
481+ displayname,
490482 } ;
491483
492484 let response = self
@@ -515,13 +507,11 @@ impl HomeserverConnection for SynapseConnection {
515507 ) ]
516508 async fn unset_displayname ( & self , localpart : & str ) -> Result < ( ) , anyhow:: Error > {
517509 #[ derive( Serialize ) ]
518- struct Request {
519- localpart : String ,
510+ struct Request < ' a > {
511+ localpart : & ' a str ,
520512 }
521513
522- let body = Request {
523- localpart : localpart. to_owned ( ) ,
524- } ;
514+ let body = Request { localpart } ;
525515
526516 let response = self
527517 . post ( "_synapse/mas/unset_displayname" )
@@ -549,13 +539,11 @@ impl HomeserverConnection for SynapseConnection {
549539 ) ]
550540 async fn allow_cross_signing_reset ( & self , localpart : & str ) -> Result < ( ) , anyhow:: Error > {
551541 #[ derive( Serialize ) ]
552- struct Request {
553- localpart : String ,
542+ struct Request < ' a > {
543+ localpart : & ' a str ,
554544 }
555545
556- let body = Request {
557- localpart : localpart. to_owned ( ) ,
558- } ;
546+ let body = Request { localpart } ;
559547
560548 let response = self
561549 . post ( "_synapse/mas/allow_cross_signing_reset" )
0 commit comments