Skip to content

feature request: allow a use of a custom DeserializeSeed for Range::rows() #599

@richardbrodie

Description

@richardbrodie

Feature Request

I have the situation where I need to do some stateful deserialization on a couple of columns because their names can only be known at runtime. The usual serde decorators aren't sufficient and I want to use Range::rows() and DeserializeSeed instead.

I'm having trouble because there doesn't seem to be a way to bridge &[Data] and my custom visit_seq.

// minimal example
let mut workbook: Xlsx<BufReader<File>> = open_workbook(&path).unwrap();
let range = workbook.worksheet_range("Sheet").unwrap();
let mut rows = range.rows();
let header_row = rows.next().unwrap();
let headers: HashMap<String, usize> = header_row
    .iter()
    .enumerate()
    .map(|(idx, val)| (val.to_string(), idx))
    .collect();
let seed = RowSeed {
    headers: headers,
    runtime_info: "something".into(),
};
let data_row = rows.next().unwrap();
/* what goes here? */
let row: RowStruct = seed.deserialize(/* and here? */).unwrap();

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