cargo fmt

This commit is contained in:
occheung 2024-09-20 17:08:53 +08:00
parent 8e28d12ad0
commit e52aa77068
2 changed files with 42 additions and 6 deletions

View File

@ -785,7 +785,11 @@ pub fn main(timer: GlobalTimer, cfg: Config) {
let cfg = Rc::new(cfg); let cfg = Rc::new(cfg);
let restart_idle = Rc::new(Semaphore::new(1, 1)); let restart_idle = Rc::new(Semaphore::new(1, 1));
mgmt::start(cfg.clone(), restart_idle.clone(), Some((&aux_mutex, &drtio_routing_table, timer))); mgmt::start(
cfg.clone(),
restart_idle.clone(),
Some((&aux_mutex, &drtio_routing_table, timer)),
);
task::spawn(async move { task::spawn(async move {
let connection = Rc::new(Semaphore::new(1, 1)); let connection = Rc::new(Semaphore::new(1, 1));

View File

@ -761,7 +761,13 @@ mod local_coremgmt {
Ok(()) Ok(())
} }
pub async fn config_write(stream: &mut TcpStream, cfg: &Rc<Config>, key: &String, value: Vec<u8>, restart_idle: &Rc<Semaphore>) -> Result<()> { pub async fn config_write(
stream: &mut TcpStream,
cfg: &Rc<Config>,
key: &String,
value: Vec<u8>,
restart_idle: &Rc<Semaphore>,
) -> Result<()> {
let value = cfg.write(&key, value); let value = cfg.write(&key, value);
if value.is_ok() { if value.is_ok() {
debug!("write success"); debug!("write success");
@ -777,7 +783,12 @@ mod local_coremgmt {
Ok(()) Ok(())
} }
pub async fn config_remove(stream: &mut TcpStream, cfg: &Rc<Config>, key: &String, restart_idle: &Rc<Semaphore>) -> Result<()> { pub async fn config_remove(
stream: &mut TcpStream,
cfg: &Rc<Config>,
key: &String,
restart_idle: &Rc<Semaphore>,
) -> Result<()> {
debug!("erase key: {}", key); debug!("erase key: {}", key);
let value = cfg.remove(&key); let value = cfg.remove(&key);
if value.is_ok() { if value.is_ok() {
@ -894,11 +905,28 @@ async fn handle_connection(
buffer.set_len(len); buffer.set_len(len);
} }
read_chunk(stream, &mut buffer).await?; read_chunk(stream, &mut buffer).await?;
process!(stream, _drtio_tuple, _destination, config_write, &cfg, &key, buffer, &restart_idle) process!(
stream,
_drtio_tuple,
_destination,
config_write,
&cfg,
&key,
buffer,
&restart_idle
)
} }
Request::ConfigRemove => { Request::ConfigRemove => {
let key = read_key(stream).await?; let key = read_key(stream).await?;
process!(stream, _drtio_tuple, _destination, config_remove, &cfg, &key, &restart_idle) process!(
stream,
_drtio_tuple,
_destination,
config_remove,
&cfg,
&key,
&restart_idle
)
} }
Request::Reboot => { Request::Reboot => {
process!(stream, _drtio_tuple, _destination, reboot) process!(stream, _drtio_tuple, _destination, reboot)
@ -926,7 +954,11 @@ async fn handle_connection(
} }
} }
pub fn start(cfg: Rc<Config>, restart_idle: Rc<Semaphore>, drtio_tuple: Option<(&Rc<Mutex<bool>>, &Rc<RefCell<RoutingTable>>, GlobalTimer)>) { pub fn start(
cfg: Rc<Config>,
restart_idle: Rc<Semaphore>,
drtio_tuple: Option<(&Rc<Mutex<bool>>, &Rc<RefCell<RoutingTable>>, GlobalTimer)>,
) {
let drtio_tuple = let drtio_tuple =
drtio_tuple.map(|(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer)); drtio_tuple.map(|(aux_mutex, routing_table, timer)| (aux_mutex.clone(), routing_table.clone(), timer));
task::spawn(async move { task::spawn(async move {