coremgmt: remove unnecsaary cursors
This commit is contained in:
parent
b47a1d0907
commit
25835868b7
|
@ -135,7 +135,7 @@ async fn read_key(stream: &mut TcpStream) -> Result<String> {
|
|||
#[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<u8>,
|
||||
) -> 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(),
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn clear_log() {
|
|||
pub struct Manager<'a> {
|
||||
cfg: &'a mut Config,
|
||||
last_log: Sliceable,
|
||||
config_payload: Cursor<Vec<u8>>,
|
||||
config_payload: Vec<u8>,
|
||||
last_value: Sliceable,
|
||||
image_payload: Vec<u8>,
|
||||
}
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue