Add helpers
This commit is contained in:
@@ -4523,7 +4523,11 @@ pub fn req_uri_to_url(uri: &Uri) -> Result<Url, UriError> {
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn extltref<'a, 'b, T>(t: &'a T) -> &'b T {
|
||||
pub unsafe fn extltref<'a, 'b, T>(x: &'a T) -> &'b T {
|
||||
&*(x as *const T)
|
||||
}
|
||||
|
||||
pub unsafe fn extltref2<'a, 'b, T>(t: &'a T) -> &'b T {
|
||||
core::mem::transmute(t)
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,13 @@ impl SeriesRange {
|
||||
SeriesRange::PulseRange(x) => x.end - x.beg,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_time(&self) -> Option<NanoRange> {
|
||||
match self {
|
||||
SeriesRange::TimeRange(x) => Some(x.clone()),
|
||||
SeriesRange::PulseRange(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for SeriesRange {
|
||||
|
||||
@@ -74,6 +74,15 @@ impl RetentionTime {
|
||||
RetentionTime::Long => 12,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(x: &str) -> Result<Self, Error> {
|
||||
match x {
|
||||
"short" => Ok(Self::Short),
|
||||
"medium" => Ok(Self::Medium),
|
||||
"long" => Ok(Self::Long),
|
||||
_ => Err(Error::Parse),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for RetentionTime {
|
||||
|
||||
Reference in New Issue
Block a user