@@ -122,8 +122,8 @@ impl HomeserverConnection for SynapseConnection {
122
122
) ]
123
123
async fn provision_user ( & self , request : & ProvisionRequest ) -> Result < bool , anyhow:: Error > {
124
124
#[ derive( Serialize ) ]
125
- struct Request {
126
- localpart : String ,
125
+ struct Request < ' a > {
126
+ localpart : & ' a str ,
127
127
#[ serde( skip_serializing_if = "Option::is_none" ) ]
128
128
set_displayname : Option < String > ,
129
129
#[ serde( skip_serializing_if = "std::ops::Not::not" ) ]
@@ -139,7 +139,7 @@ impl HomeserverConnection for SynapseConnection {
139
139
}
140
140
141
141
let mut body = Request {
142
- localpart : request. localpart ( ) . to_owned ( ) ,
142
+ localpart : request. localpart ( ) ,
143
143
set_displayname : None ,
144
144
unset_displayname : false ,
145
145
set_avatar_url : None ,
@@ -243,17 +243,17 @@ impl HomeserverConnection for SynapseConnection {
243
243
initial_display_name : Option < & str > ,
244
244
) -> Result < ( ) , anyhow:: Error > {
245
245
#[ 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 ,
249
249
#[ serde( skip_serializing_if = "Option::is_none" ) ]
250
- display_name : Option < String > ,
250
+ display_name : Option < & ' a str > ,
251
251
}
252
252
253
253
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,
257
257
} ;
258
258
259
259
let response = self
@@ -288,16 +288,16 @@ impl HomeserverConnection for SynapseConnection {
288
288
display_name : & str ,
289
289
) -> Result < ( ) , anyhow:: Error > {
290
290
#[ 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 ,
295
295
}
296
296
297
297
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,
301
301
} ;
302
302
303
303
let response = self
@@ -327,14 +327,14 @@ impl HomeserverConnection for SynapseConnection {
327
327
) ]
328
328
async fn delete_device ( & self , localpart : & str , device_id : & str ) -> Result < ( ) , anyhow:: Error > {
329
329
#[ 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 ,
333
333
}
334
334
335
335
let body = Request {
336
- localpart : localpart . to_owned ( ) ,
337
- device_id : device_id . to_owned ( ) ,
336
+ localpart,
337
+ device_id,
338
338
} ;
339
339
340
340
let response = self
@@ -368,15 +368,12 @@ impl HomeserverConnection for SynapseConnection {
368
368
devices : HashSet < String > ,
369
369
) -> Result < ( ) , anyhow:: Error > {
370
370
#[ derive( Serialize ) ]
371
- struct Request {
372
- localpart : String ,
373
- devices : Vec < String > ,
371
+ struct Request < ' a > {
372
+ localpart : & ' a str ,
373
+ devices : HashSet < String > ,
374
374
}
375
375
376
- let body = Request {
377
- localpart : localpart. to_owned ( ) ,
378
- devices : devices. into_iter ( ) . collect ( ) ,
379
- } ;
376
+ let body = Request { localpart, devices } ;
380
377
381
378
let response = self
382
379
. post ( "_synapse/mas/sync_devices" )
@@ -405,15 +402,12 @@ impl HomeserverConnection for SynapseConnection {
405
402
) ]
406
403
async fn delete_user ( & self , localpart : & str , erase : bool ) -> Result < ( ) , anyhow:: Error > {
407
404
#[ derive( Serialize ) ]
408
- struct Request {
409
- localpart : String ,
405
+ struct Request < ' a > {
406
+ localpart : & ' a str ,
410
407
erase : bool ,
411
408
}
412
409
413
- let body = Request {
414
- localpart : localpart. to_owned ( ) ,
415
- erase,
416
- } ;
410
+ let body = Request { localpart, erase } ;
417
411
418
412
let response = self
419
413
. post ( "_synapse/mas/delete_user" )
@@ -441,13 +435,11 @@ impl HomeserverConnection for SynapseConnection {
441
435
) ]
442
436
async fn reactivate_user ( & self , localpart : & str ) -> Result < ( ) , anyhow:: Error > {
443
437
#[ derive( Serialize ) ]
444
- struct Request {
445
- localpart : String ,
438
+ struct Request < ' a > {
439
+ localpart : & ' a str ,
446
440
}
447
441
448
- let body = Request {
449
- localpart : localpart. to_owned ( ) ,
450
- } ;
442
+ let body = Request { localpart } ;
451
443
452
444
let response = self
453
445
. post ( "_synapse/mas/reactivate_user" )
@@ -479,14 +471,14 @@ impl HomeserverConnection for SynapseConnection {
479
471
displayname : & str ,
480
472
) -> Result < ( ) , anyhow:: Error > {
481
473
#[ derive( Serialize ) ]
482
- struct Request {
483
- localpart : String ,
484
- displayname : String ,
474
+ struct Request < ' a > {
475
+ localpart : & ' a str ,
476
+ displayname : & ' a str ,
485
477
}
486
478
487
479
let body = Request {
488
- localpart : localpart . to_owned ( ) ,
489
- displayname : displayname . to_owned ( ) ,
480
+ localpart,
481
+ displayname,
490
482
} ;
491
483
492
484
let response = self
@@ -515,13 +507,11 @@ impl HomeserverConnection for SynapseConnection {
515
507
) ]
516
508
async fn unset_displayname ( & self , localpart : & str ) -> Result < ( ) , anyhow:: Error > {
517
509
#[ derive( Serialize ) ]
518
- struct Request {
519
- localpart : String ,
510
+ struct Request < ' a > {
511
+ localpart : & ' a str ,
520
512
}
521
513
522
- let body = Request {
523
- localpart : localpart. to_owned ( ) ,
524
- } ;
514
+ let body = Request { localpart } ;
525
515
526
516
let response = self
527
517
. post ( "_synapse/mas/unset_displayname" )
@@ -549,13 +539,11 @@ impl HomeserverConnection for SynapseConnection {
549
539
) ]
550
540
async fn allow_cross_signing_reset ( & self , localpart : & str ) -> Result < ( ) , anyhow:: Error > {
551
541
#[ derive( Serialize ) ]
552
- struct Request {
553
- localpart : String ,
542
+ struct Request < ' a > {
543
+ localpart : & ' a str ,
554
544
}
555
545
556
- let body = Request {
557
- localpart : localpart. to_owned ( ) ,
558
- } ;
546
+ let body = Request { localpart } ;
559
547
560
548
let response = self
561
549
. post ( "_synapse/mas/allow_cross_signing_reset" )
0 commit comments