rustc panics

This commit is contained in:
Dominik Werder
2023-07-18 11:27:39 +02:00
parent 2054f6c23f
commit 91947dec0f
49 changed files with 982 additions and 679 deletions
+33 -4
View File
@@ -36,10 +36,11 @@ use std::time::Duration;
use timeunits::*;
use url::Url;
pub const APP_JSON: &'static str = "application/json";
pub const APP_JSON_LINES: &'static str = "application/jsonlines";
pub const APP_OCTET: &'static str = "application/octet-stream";
pub const ACCEPT_ALL: &'static str = "*/*";
pub const APP_JSON: &str = "application/json";
pub const APP_JSON_LINES: &str = "application/jsonlines";
pub const APP_OCTET: &str = "application/octet-stream";
pub const ACCEPT_ALL: &str = "*/*";
pub const X_DAQBUF_REQID: &str = "x-daqbuffer-request-id";
pub const CONNECTION_STATUS_DIV: u64 = timeunits::DAY;
pub const TS_MSP_GRID_UNIT: u64 = timeunits::SEC * 10;
@@ -1100,6 +1101,14 @@ impl Shape {
let ret = serde_json::from_str(s)?;
Ok(ret)
}
pub fn ele_count(&self) -> u64 {
match self {
Shape::Scalar => 1,
Shape::Wave(n) => *n as u64,
Shape::Image(n, m) => *n as u64 * *m as u64,
}
}
}
impl AppendToUrl for Shape {
@@ -2987,3 +2996,23 @@ mod test_parse {
assert_eq!(a.get("shape").unwrap(), "Image(3, 4)");
}
}
pub struct ReqCtx {
reqid: String,
}
impl ReqCtx {
pub fn new<S>(reqid: S) -> std::sync::Arc<Self>
where
S: Into<String>,
{
let ret = Self { reqid: reqid.into() };
std::sync::Arc::new(ret)
}
pub fn reqid(&self) -> &str {
&self.reqid
}
}
pub type ReqCtxArc = std::sync::Arc<ReqCtx>;