forked from ISISNeutronMuon/digital-muon-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattribute.rs
More file actions
28 lines (25 loc) · 977 Bytes
/
attribute.rs
File metadata and controls
28 lines (25 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use super::{
error::{ConvertResult, NexusHDF5Result},
AttributeExt,
};
use crate::run_engine::NexusDateTime;
use hdf5::{types::VarLenUnicode, Attribute};
impl AttributeExt for Attribute {
#[tracing::instrument(skip_all, level = "trace", err(level = "warn"))]
fn get_datetime(&self) -> NexusHDF5Result<NexusDateTime> {
let string: VarLenUnicode = self.read_scalar().err_attribute(self)?;
string.parse().err_attribute(self)
}
#[tracing::instrument(skip_all, level = "trace", err(level = "warn"))]
fn set_string(&self, value: &str) -> NexusHDF5Result<()> {
self.write_scalar(&value.parse::<VarLenUnicode>().err_attribute(self)?)
.err_attribute(self)
}
#[tracing::instrument(skip_all, level = "trace", err(level = "warn"))]
fn get_string(&self) -> NexusHDF5Result<String> {
Ok(self
.read_scalar::<VarLenUnicode>()
.err_attribute(self)?
.to_string())
}
}