diff --git a/src/runtime/src/mgmt.rs b/src/runtime/src/mgmt.rs index 33b883e..c51fc73 100644 --- a/src/runtime/src/mgmt.rs +++ b/src/runtime/src/mgmt.rs @@ -135,7 +135,7 @@ async fn read_key(stream: &mut TcpStream) -> Result { #[cfg(has_drtio)] mod remote_coremgmt { use core_io::Read; - use io::{Cursor, ProtoWrite}; + use io::ProtoWrite; use libboard_artiq::{drtioaux_async, drtioaux_proto::{Packet, MASTER_PAYLOAD_MAX_SIZE}}; @@ -426,7 +426,7 @@ mod remote_coremgmt { key: &String, value: Vec, ) -> Result<()> { - let mut message = Cursor::new(Vec::with_capacity(key.len() + value.len() + 4 * 2)); + let mut message = Vec::with_capacity(key.len() + value.len() + 4 * 2); message.write_string(key).unwrap(); message.write_bytes(&value).unwrap(); @@ -435,7 +435,7 @@ mod remote_coremgmt { aux_mutex, routing_table, timer, - message.get_ref(), + &message, |slice, status, len: usize| Packet::CoreMgmtConfigWriteRequest { destination: destination, last: status.is_last(), diff --git a/src/satman/src/mgmt.rs b/src/satman/src/mgmt.rs index 8b7e569..9866999 100644 --- a/src/satman/src/mgmt.rs +++ b/src/satman/src/mgmt.rs @@ -48,7 +48,7 @@ pub fn clear_log() { pub struct Manager<'a> { cfg: &'a mut Config, last_log: Sliceable, - config_payload: Cursor>, + config_payload: Vec, last_value: Sliceable, image_payload: Vec, } @@ -58,7 +58,7 @@ impl<'a> Manager<'_> { Manager { cfg: cfg, last_log: Sliceable::new(0, Vec::new()), - config_payload: Cursor::new(Vec::new()), + config_payload: Vec::new(), last_value: Sliceable::new(0, Vec::new()), image_payload: Vec::new(), } @@ -92,17 +92,14 @@ impl<'a> Manager<'_> { } pub fn clear_config_data(&mut self) { - self.config_payload.get_mut().clear(); - self.config_payload.set_position(0); + self.config_payload.clear(); } pub fn write_config(&mut self) -> Result<()> { - let key = self - .config_payload - .read_string() - .map_err(|_err| error!("error on reading key"))?; + let mut payload = &self.config_payload[..]; + let key = payload.read_string().map_err(|_err| error!("error on reading key"))?; debug!("write key: {}", key); - let value = self.config_payload.read_bytes().unwrap(); + let value = payload.read_bytes().unwrap(); self.cfg .write(&key, value)