@@ -111,6 +111,8 @@ pub trait SeleniumManager {
111111
112112 fn get_config ( & self ) -> & ManagerConfig ;
113113
114+ fn get_config_mut ( & mut self ) -> & mut ManagerConfig ;
115+
114116 fn set_config ( & mut self , config : ManagerConfig ) ;
115117
116118 fn get_logger ( & self ) -> & Logger ;
@@ -362,19 +364,17 @@ pub trait SeleniumManager {
362364 }
363365
364366 fn set_os ( & mut self , os : String ) {
365- let mut config = ManagerConfig :: clone ( self . get_config ( ) ) ;
367+ let mut config = self . get_config_mut ( ) ;
366368 config. os = os;
367- self . set_config ( config) ;
368369 }
369370
370371 fn get_arch ( & self ) -> & str {
371372 self . get_config ( ) . arch . as_str ( )
372373 }
373374
374375 fn set_arch ( & mut self , arch : String ) {
375- let mut config = ManagerConfig :: clone ( self . get_config ( ) ) ;
376+ let mut config = self . get_config_mut ( ) ;
376377 config. arch = arch;
377- self . set_config ( config) ;
378378 }
379379
380380 fn get_browser_version ( & self ) -> & str {
@@ -383,9 +383,8 @@ pub trait SeleniumManager {
383383
384384 fn set_browser_version ( & mut self , browser_version : String ) {
385385 if !browser_version. is_empty ( ) {
386- let mut config = ManagerConfig :: clone ( self . get_config ( ) ) ;
386+ let mut config = self . get_config_mut ( ) ;
387387 config. browser_version = browser_version;
388- self . set_config ( config) ;
389388 }
390389 }
391390
@@ -395,9 +394,8 @@ pub trait SeleniumManager {
395394
396395 fn set_driver_version ( & mut self , driver_version : String ) {
397396 if !driver_version. is_empty ( ) {
398- let mut config = ManagerConfig :: clone ( self . get_config ( ) ) ;
397+ let mut config = self . get_config_mut ( ) ;
399398 config. driver_version = driver_version;
400- self . set_config ( config) ;
401399 }
402400 }
403401
@@ -407,22 +405,20 @@ pub trait SeleniumManager {
407405
408406 fn set_browser_path ( & mut self , browser_path : String ) {
409407 if !browser_path. is_empty ( ) {
410- let mut config = ManagerConfig :: clone ( self . get_config ( ) ) ;
408+ let mut config = self . get_config_mut ( ) ;
411409 config. browser_path = browser_path;
412- self . set_config ( config) ;
413410 }
414411 }
415412
416413 fn get_proxy ( & self ) -> & str {
417414 self . get_config ( ) . proxy . as_str ( )
418415 }
419416
420- fn set_proxy ( & mut self , proxy : String ) -> Result < ( ) , String > {
417+ fn set_proxy ( & mut self , proxy : String ) -> Result < ( ) , Box < dyn Error > > {
421418 if !proxy. is_empty ( ) {
422- let mut config = ManagerConfig :: clone ( self . get_config ( ) ) ;
423- config. proxy = proxy. to_string ( ) ;
424- self . set_config ( config) ;
425419 self . get_logger ( ) . debug ( format ! ( "Using proxy: {}" , & proxy) ) ;
420+ let mut config = self . get_config_mut ( ) ;
421+ config. proxy = proxy;
426422 self . update_http_client ( ) ?;
427423 }
428424 Ok ( ( ) )
@@ -432,12 +428,11 @@ pub trait SeleniumManager {
432428 self . get_config ( ) . timeout
433429 }
434430
435- fn set_timeout ( & mut self , timeout : u64 ) -> Result < ( ) , String > {
436- let default_timeout = self . get_config ( ) . timeout . to_owned ( ) ;
431+ fn set_timeout ( & mut self , timeout : u64 ) -> Result < ( ) , Box < dyn Error > > {
432+ let mut config = self . get_config_mut ( ) ;
433+ let default_timeout = config. timeout ;
437434 if timeout != default_timeout {
438- let mut config = ManagerConfig :: clone ( self . get_config ( ) ) ;
439435 config. timeout = timeout;
440- self . set_config ( config) ;
441436 self . get_logger ( )
442437 . debug ( format ! ( "Using timeout of {} seconds" , timeout) ) ;
443438 self . update_http_client ( ) ?;
0 commit comments