@@ -2,7 +2,6 @@ use std::{
22 collections:: { BTreeMap , HashMap } ,
33 io:: Cursor ,
44 mem:: ManuallyDrop ,
5- ops:: Deref ,
65 sync:: Arc ,
76 time:: Duration ,
87} ;
@@ -205,7 +204,7 @@ impl OlmMachine {
205204 mut passphrase : Option < String > ,
206205 ) -> Result < Arc < Self > , CryptoStoreError > {
207206 let user_id = parse_user_id ( & user_id) ?;
208- let device_id = device_id. as_str ( ) . into ( ) ;
207+ let device_id = device_id. into ( ) ;
209208 let runtime = Runtime :: new ( ) . expect ( "Couldn't create a tokio runtime" ) ;
210209
211210 let store = runtime
@@ -215,7 +214,7 @@ impl OlmMachine {
215214
216215 let inner = runtime. block_on ( InnerMachine :: with_store (
217216 & user_id,
218- device_id,
217+ & device_id,
219218 Arc :: new ( store) ,
220219 None ,
221220 ) ) ?;
@@ -353,7 +352,7 @@ impl OlmMachine {
353352
354353 Ok ( self
355354 . runtime
356- . block_on ( self . inner . get_device ( & user_id, device_id. as_str ( ) . into ( ) , timeout) ) ?
355+ . block_on ( self . inner . get_device ( & user_id, & device_id. into ( ) , timeout) ) ?
357356 . map ( |d| d. into ( ) ) )
358357 }
359358
@@ -378,7 +377,7 @@ impl OlmMachine {
378377 let user_id = UserId :: parse ( user_id) ?;
379378 let device = self . runtime . block_on ( self . inner . get_device (
380379 & user_id,
381- device_id. as_str ( ) . into ( ) ,
380+ & device_id. clone ( ) . into ( ) ,
382381 None ,
383382 ) ) ?;
384383
@@ -399,11 +398,8 @@ impl OlmMachine {
399398 ) -> Result < ( ) , CryptoStoreError > {
400399 let user_id = parse_user_id ( & user_id) ?;
401400
402- let device = self . runtime . block_on ( self . inner . get_device (
403- & user_id,
404- device_id. as_str ( ) . into ( ) ,
405- None ,
406- ) ) ?;
401+ let device =
402+ self . runtime . block_on ( self . inner . get_device ( & user_id, & device_id. into ( ) , None ) ) ?;
407403
408404 if let Some ( device) = device {
409405 self . runtime . block_on ( device. set_local_trust ( trust_state) ) ?;
@@ -587,7 +583,7 @@ impl OlmMachine {
587583 pub fn update_tracked_users ( & self , users : Vec < String > ) -> Result < ( ) , CryptoStoreError > {
588584 let users: Vec < UserId > = users. into_iter ( ) . filter_map ( |u| UserId :: parse ( u) . ok ( ) ) . collect ( ) ;
589585
590- self . runtime . block_on ( self . inner . update_tracked_users ( users. iter ( ) . map ( Deref :: deref ) ) ) ?;
586+ self . runtime . block_on ( self . inner . update_tracked_users ( users. iter ( ) ) ) ?;
591587
592588 Ok ( ( ) )
593589 }
@@ -621,10 +617,7 @@ impl OlmMachine {
621617 ) -> Result < Option < Request > , CryptoStoreError > {
622618 let users: Vec < UserId > = users. into_iter ( ) . filter_map ( |u| UserId :: parse ( u) . ok ( ) ) . collect ( ) ;
623619
624- Ok ( self
625- . runtime
626- . block_on ( self . inner . get_missing_sessions ( users. iter ( ) . map ( Deref :: deref) ) ) ?
627- . map ( |r| r. into ( ) ) )
620+ Ok ( self . runtime . block_on ( self . inner . get_missing_sessions ( users. iter ( ) ) ) ?. map ( |r| r. into ( ) ) )
628621 }
629622
630623 /// Get the stored room settings, such as the encryption algorithm or
@@ -750,11 +743,8 @@ impl OlmMachine {
750743 let users: Vec < UserId > = users. into_iter ( ) . filter_map ( |u| UserId :: parse ( u) . ok ( ) ) . collect ( ) ;
751744
752745 let room_id = RoomId :: parse ( room_id) ?;
753- let requests = self . runtime . block_on ( self . inner . share_room_key (
754- & room_id,
755- users. iter ( ) . map ( Deref :: deref) ,
756- settings,
757- ) ) ?;
746+ let requests =
747+ self . runtime . block_on ( self . inner . share_room_key ( & room_id, users. iter ( ) , settings) ) ?;
758748
759749 Ok ( requests. into_iter ( ) . map ( |r| r. as_ref ( ) . into ( ) ) . collect ( ) )
760750 }
@@ -835,10 +825,10 @@ impl OlmMachine {
835825 share_strategy : CollectStrategy ,
836826 ) -> Result < Option < Request > , CryptoStoreError > {
837827 let user_id = parse_user_id ( & user_id) ?;
838- let device_id = device_id. as_str ( ) . into ( ) ;
828+ let device_id = device_id. into ( ) ;
839829 let content = serde_json:: from_str ( & content) ?;
840830
841- let device = self . runtime . block_on ( self . inner . get_device ( & user_id, device_id, None ) ) ?;
831+ let device = self . runtime . block_on ( self . inner . get_device ( & user_id, & device_id, None ) ) ?;
842832
843833 if let Some ( device) = device {
844834 let encrypted_content = self . runtime . block_on ( device. encrypt_event_raw (
@@ -848,7 +838,7 @@ impl OlmMachine {
848838 ) ) ?;
849839
850840 let request = ToDeviceRequest :: new (
851- user_id. as_ref ( ) ,
841+ & user_id,
852842 DeviceIdOrAllDevices :: DeviceId ( device_id. to_owned ( ) ) ,
853843 "m.room.encrypted" ,
854844 encrypted_content. cast ( ) ,
@@ -1265,13 +1255,13 @@ impl OlmMachine {
12651255 methods : Vec < String > ,
12661256 ) -> Result < Option < RequestVerificationResult > , CryptoStoreError > {
12671257 let user_id = parse_user_id ( & user_id) ?;
1268- let device_id = device_id. as_str ( ) . into ( ) ;
1258+ let device_id = device_id. into ( ) ;
12691259
12701260 let methods = methods. into_iter ( ) . map ( VerificationMethod :: from) . collect ( ) ;
12711261
12721262 Ok (
12731263 if let Some ( device) =
1274- self . runtime . block_on ( self . inner . get_device ( & user_id, device_id, None ) ) ?
1264+ self . runtime . block_on ( self . inner . get_device ( & user_id, & device_id, None ) ) ?
12751265 {
12761266 let ( verification, request) = device. request_verification_with_methods ( methods) ;
12771267
@@ -1357,11 +1347,11 @@ impl OlmMachine {
13571347 device_id : String ,
13581348 ) -> Result < Option < StartSasResult > , CryptoStoreError > {
13591349 let user_id = parse_user_id ( & user_id) ?;
1360- let device_id = device_id. as_str ( ) . into ( ) ;
1350+ let device_id = device_id. into ( ) ;
13611351
13621352 Ok (
13631353 if let Some ( device) =
1364- self . runtime . block_on ( self . inner . get_device ( & user_id, device_id, None ) ) ?
1354+ self . runtime . block_on ( self . inner . get_device ( & user_id, & device_id, None ) ) ?
13651355 {
13661356 let ( sas, request) = self . runtime . block_on ( device. start_verification ( ) ) ?;
13671357
0 commit comments