drtio-mgmt: fmt

This commit is contained in:
occheung 2024-08-22 17:46:18 +08:00
parent 37945e3a29
commit 5a8db1dcf6
2 changed files with 13 additions and 12 deletions

View File

@ -1218,9 +1218,7 @@ fn process_aux_packet(
core_manager.clear_data();
}
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: succeeded })?;
Ok(())
drtioaux::send(0, &drtioaux::Packet::CoreMgmtAck { succeeded: succeeded })
}
drtioaux::Packet::CoreMgmtConfigRemoveRequest {
destination: _destination,

View File

@ -21,7 +21,7 @@ pub fn byte_to_level_filter(level_byte: u8) -> Result<log::LevelFilter> {
lv => {
error!("unknown log level: {}", lv);
return Err(());
},
}
})
}
@ -70,14 +70,13 @@ impl<'a> Manager<'_> {
}
pub fn fetch_config_value(&mut self, key: &str) -> Result<()> {
self.cfg.read(&key)
self.cfg
.read(&key)
.map(|value| {
debug!("got value");
self.last_value = Sliceable::new(0, value)
})
.map_err(|_| {
warn!("read error: no such key")
})
.map_err(|_| warn!("read error: no such key"))
}
pub fn get_config_value_slice(&mut self, data_slice: &mut [u8; CORE_MGMT_PAYLOAD_MAX_SIZE]) -> SliceMeta {
@ -94,18 +93,22 @@ impl<'a> Manager<'_> {
}
pub fn write_config(&mut self) -> Result<()> {
let key = self.current_payload.read_string().map_err(
|_err| error!("error on reading key"))?;
let key = self
.current_payload
.read_string()
.map_err(|_err| error!("error on reading key"))?;
let value = self.current_payload.read_bytes().unwrap();
self.cfg.write(&key, value)
self.cfg
.write(&key, value)
.map(|()| debug!("write success"))
.map_err(|err| error!("failed to write: {:?}", err))
}
pub fn remove_config(&mut self, key: &str) -> Result<()> {
debug!("erase key: {}", key);
self.cfg.remove(&key)
self.cfg
.remove(&key)
.map(|()| debug!("erase success"))
.map_err(|err| warn!("failed to erase: {:?}", err))
}