For example, we have the following code in dstate:
fn get_state(path: &Path) -> Result<String, DStateError> {
let mut stat_path = path.to_path_buf();
stat_path.push("stat");
let line = read_to_string_single(&stat_path)?;
let fields: Vec<_> = line.split_whitespace().collect();
Ok(fields
.get(2)
.ok_or(DStateError::InvalidStatFile)?
.to_string())
}
With some code changes, we should allow passing:
#[filestruct(parser = get_state)]
For example, we have the following code in dstate:
With some code changes, we should allow passing:
#[filestruct(parser = get_state)]