From 299cecd9623840571f2a9199727167d387c547ac Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 4 Sep 2024 13:22:17 +0800 Subject: [PATCH] cargo fmt --- src/runtime/src/mgmt.rs | 82 ++++++++--------------------------------- 1 file changed, 16 insertions(+), 66 deletions(-) diff --git a/src/runtime/src/mgmt.rs b/src/runtime/src/mgmt.rs index 3329626..484fb4a 100644 --- a/src/runtime/src/mgmt.rs +++ b/src/runtime/src/mgmt.rs @@ -781,43 +781,18 @@ async fn handle_connection( match msg { Request::GetLog => process!(stream, _drtio_tuple, _destination, get_log), Request::ClearLog => process!(stream, _drtio_tuple, _destination, clear_log), - Request::PullLog => process!( - stream, - _drtio_tuple, - _destination, - pull_log, - &pull_id - ), + Request::PullLog => process!(stream, _drtio_tuple, _destination, pull_log, &pull_id), Request::SetLogFilter => { let lvl = read_log_level_filter(stream).await?; - process!( - stream, - _drtio_tuple, - _destination, - set_log_filter, - lvl - ) + process!(stream, _drtio_tuple, _destination, set_log_filter, lvl) } Request::SetUartLogFilter => { let lvl = read_log_level_filter(stream).await?; - process!( - stream, - _drtio_tuple, - _destination, - set_uart_log_filter, - lvl - ) + process!(stream, _drtio_tuple, _destination, set_uart_log_filter, lvl) } Request::ConfigRead => { let key = read_key(stream).await?; - process!( - stream, - _drtio_tuple, - _destination, - config_read, - &cfg, - &key - ) + process!(stream, _drtio_tuple, _destination, config_read, &cfg, &key) } Request::ConfigWrite => { let key = read_key(stream).await?; @@ -828,26 +803,11 @@ async fn handle_connection( buffer.set_len(len); } read_chunk(stream, &mut buffer).await?; - process!( - stream, - _drtio_tuple, - _destination, - config_write, - &cfg, - &key, - buffer - ) + process!(stream, _drtio_tuple, _destination, config_write, &cfg, &key, buffer) } Request::ConfigRemove => { let key = read_key(stream).await?; - process!( - stream, - _drtio_tuple, - _destination, - config_remove, - &cfg, - &key - ) + process!(stream, _drtio_tuple, _destination, config_remove, &cfg, &key) } Request::Reboot => { process!(stream, _drtio_tuple, _destination, reboot) @@ -856,12 +816,7 @@ async fn handle_connection( process!(stream, _drtio_tuple, _destination, config_erase) } Request::DebugAllocator => { - process!( - stream, - _drtio_tuple, - _destination, - debug_allocator - ) + process!(stream, _drtio_tuple, _destination, debug_allocator) } }?; } @@ -869,15 +824,10 @@ async fn handle_connection( pub fn start( cfg: Config, - drtio_tuple: Option<( - &Rc>, - &Rc>, - GlobalTimer, - )>, + drtio_tuple: Option<(&Rc>, &Rc>, GlobalTimer)>, ) { - let drtio_tuple = drtio_tuple.map( - |(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer) - ); + let drtio_tuple = + drtio_tuple.map(|(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer)); task::spawn(async move { let pull_id = Rc::new(RefCell::new(0u32)); let cfg = Rc::new(cfg); @@ -891,12 +841,12 @@ pub fn start( info!("received connection"); // Avoid consuming the tuple // Keep the borrowed value on stack - let drtio_tuple = drtio_tuple.as_ref().map( - |(aux_mutex, routing_table, timer)| (aux_mutex, routing_table.borrow(), *timer) - ); - let drtio_tuple = drtio_tuple.as_ref().map( - |(aux_mutex, routing_table, timer)| (*aux_mutex, routing_table.deref(), *timer) - ); + let drtio_tuple = drtio_tuple + .as_ref() + .map(|(aux_mutex, routing_table, timer)| (aux_mutex, routing_table.borrow(), *timer)); + let drtio_tuple = drtio_tuple + .as_ref() + .map(|(aux_mutex, routing_table, timer)| (*aux_mutex, routing_table.deref(), *timer)); let _ = handle_connection(&mut stream, pull_id, cfg, drtio_tuple) .await .map_err(|e| warn!("connection terminated: {:?}", e));