@@ -317,6 +317,19 @@ impl Bond {
317317 } )
318318 }
319319
320+ /// Updates the connection data in the NetworkSystem.
321+ ///
322+ /// * `connection`: Updated connection.
323+ async fn update_connection < ' a > (
324+ & self ,
325+ connection : MappedMutexGuard < ' a , BondConnection > ,
326+ ) -> zbus:: fdo:: Result < ( ) > {
327+ let actions = self . actions . lock ( ) . await ;
328+ let connection = NetworkConnection :: Bond ( connection. clone ( ) ) ;
329+ actions. send ( Action :: UpdateConnection ( connection) ) . unwrap ( ) ;
330+ Ok ( ( ) )
331+ }
332+
320333 /// Updates the controller connection data in the NetworkSystem.
321334 ///
322335 /// * `connection`: Updated connection.
@@ -347,16 +360,11 @@ impl Bond {
347360 }
348361
349362 #[ dbus_interface( property) ]
350- pub async fn set_mode ( & mut self , mode : String ) -> zbus:: fdo:: Result < ( ) > {
351- let connection = self . get_bond ( ) . await ;
352- let result = self
353- . update_controller_connection (
354- connection,
355- HashMap :: from ( [ ( "mode" . to_string ( ) , ControllerConfig :: Mode ( mode. clone ( ) ) ) ] ) ,
356- )
357- . await ;
358- self . connection = Arc :: new ( Mutex :: new ( result?) ) ;
359- Ok ( ( ) )
363+ pub async fn set_mode ( & mut self , mode : & str ) -> zbus:: fdo:: Result < ( ) > {
364+ let mut connection = self . get_bond ( ) . await ;
365+ connection. set_mode ( mode) ?;
366+
367+ self . update_connection ( connection) . await
360368 }
361369
362370 /// List of bond ports.
@@ -368,19 +376,11 @@ impl Bond {
368376 }
369377
370378 #[ dbus_interface( property) ]
371- pub async fn set_options ( & mut self , opts : String ) -> zbus:: fdo:: Result < ( ) > {
372- let connection = self . get_bond ( ) . await ;
373- let result = self
374- . update_controller_connection (
375- connection,
376- HashMap :: from ( [ (
377- "options" . to_string ( ) ,
378- ControllerConfig :: Options ( opts. clone ( ) ) ,
379- ) ] ) ,
380- )
381- . await ;
382- self . connection = Arc :: new ( Mutex :: new ( result. unwrap ( ) ) ) ;
383- Ok ( ( ) )
379+ pub async fn set_options ( & mut self , opts : & str ) -> zbus:: fdo:: Result < ( ) > {
380+ let mut connection = self . get_bond ( ) . await ;
381+ connection. set_options ( opts) ?;
382+
383+ self . update_connection ( connection) . await
384384 }
385385
386386 /// List of bond ports.
0 commit comments