This commit is contained in:
Dominik Werder
2022-09-15 15:35:20 +02:00
parent b553402422
commit 0905ee6dfc
10 changed files with 229 additions and 294 deletions
+6
View File
@@ -39,6 +39,7 @@ pub enum ChannelConnectedInfo {
pub struct ChannelStateInfo {
pub name: String,
pub addr: SocketAddrV4,
pub series: Option<SeriesId>,
pub channel_connected_info: ChannelConnectedInfo,
pub scalar_type: Option<ScalarType>,
pub shape: Option<Shape>,
@@ -169,10 +170,15 @@ impl ChannelState {
}
_ => None,
};
let series = match self {
ChannelState::Created(s) => s.series.clone(),
_ => None,
};
let interest_score = 1. / item_recv_ivl_ema.unwrap_or(1e10).max(1e-6).min(1e10);
ChannelStateInfo {
name,
addr,
series,
channel_connected_info,
scalar_type,
shape,
+3 -3
View File
@@ -385,7 +385,7 @@ impl CaMsgTy {
error!("bad buffer given for search payload {} vs {}", buf.len(), d.len());
panic!();
}
unsafe { std::ptr::copy(&d[0] as _, &mut buf[0] as _, d.len()) };
buf[0..d.len()].copy_from_slice(&d[0..d.len()]);
}
SearchRes(_) => {
error!("should not attempt to write SearchRes");
@@ -400,7 +400,7 @@ impl CaMsgTy {
error!("bad buffer given for create chan payload {} vs {}", buf.len(), d.len());
panic!();
}
unsafe { std::ptr::copy(&d[0] as _, &mut buf[0] as _, d.len()) };
buf[0..d.len()].copy_from_slice(&d[0..d.len()]);
}
CreateChanRes(_) => {}
CreateChanFail(_) => {}
@@ -438,7 +438,7 @@ macro_rules! convert_wave_value {
const STL: usize = std::mem::size_of::<ST>();
let nn = $n.min($buf.len() / STL);
let mut a = Vec::with_capacity(nn);
// TODO optimize with unsafe?
// TODO should optimize?
let mut bb = &$buf[..];
for _ in 0..nn {
let v = ST::from_be_bytes(bb[..STL].try_into()?);