Skip to content

Allow custom parsers #19

@cdown

Description

@cdown

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)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions