pub struct OptionSet {
pub selected: Option<Vec<String>>,
pub indices: Vec<u32>,
pub path: Option<String>,
pub rows: RowOptionSet,
pub jsonl: bool,
pub max: Option<u32>,
pub omit_header: bool,
pub header_row: Option<usize>,
pub data_row_index: Option<usize>,
pub detect_header: bool,
pub read_mode: ReadMode,
pub field_mode: FieldNameMode,
}Expand description
Core options with nested row options
Fields§
§selected: Option<Vec<String>>§indices: Vec<u32>§path: Option<String>§rows: RowOptionSet§jsonl: bool§max: Option<u32>§omit_header: bool§header_row: Option<usize>0-based row index of the header row. None means unset – when data_row_index is
also unset (and headers aren’t omitted), the reader runs a best-guess detection
pass instead of blindly assuming row 0; see detect::detect_header_and_data_rows.
data_row_index: Option<usize>0-based row index where actual data begins. None (the default) means immediately
after the header row (or triggers detection, per header_row’s doc above). Rows
strictly between the header row and this one are skipped entirely – neither
captured as headers nor as data – for spreadsheets that leave a note, blank, or
subtitle row between the header and the first real data row.
detect_header: boolWhether to run best-guess header/data-row detection (see
detect::detect_header_and_data_rows) when both header_row and data_row_index
are unset, instead of assuming row 0 is the header. Off (false) by default for
direct library use, so OptionSet::new(path) alone always behaves the same simple,
predictable way it always has – callers that want detection opt in explicitly via
.detect_header(). Consumers like spread-cli that want it as their own default
user experience turn it on unconditionally when building their OptionSet.
read_mode: ReadMode§field_mode: FieldNameModeImplementations§
Source§impl OptionSet
impl OptionSet
Sourcepub fn new(path_str: &str) -> Self
pub fn new(path_str: &str) -> Self
Instantiates a new option set with a path string for file operations.
Sourcepub fn sheet_name(self, name: &str) -> Self
pub fn sheet_name(self, name: &str) -> Self
Sets the sheet name for the operation.
Sourcepub fn sheet_names(self, names: &[String]) -> Self
pub fn sheet_names(self, names: &[String]) -> Self
Sets the sheet name for the operation.
Sourcepub fn sheet_index(self, index: u32) -> Self
pub fn sheet_index(self, index: u32) -> Self
Sets the sheet index.
Sourcepub fn sheet_indices(self, indices: &[u32]) -> Self
pub fn sheet_indices(self, indices: &[u32]) -> Self
Sets the sheet index.
Sourcepub fn json_lines(self) -> Self
pub fn json_lines(self) -> Self
Sets JSON Lines mode to true.
Sourcepub fn set_json_lines(self, mode: bool) -> Self
pub fn set_json_lines(self, mode: bool) -> Self
Sets JSON Lines mode
Sourcepub fn omit_header(self) -> Self
pub fn omit_header(self) -> Self
Omits the header when reading.
Sourcepub fn header_row(self, row: usize) -> Self
pub fn header_row(self, row: usize) -> Self
Sets the header row’s 0-based row index.
Sourcepub fn data_row_index(self, row: usize) -> Self
pub fn data_row_index(self, row: usize) -> Self
Sets the 0-based row index where actual data begins. Rows between the header row and this one are skipped entirely, for spreadsheets that leave a note or blank row between the header and the first real data row. If set at or before the header row, this is ignored and data capture falls back to starting immediately after the header row instead.
Sourcepub fn detect_header(self) -> Self
pub fn detect_header(self) -> Self
Opts into best-guess header/data-row detection when both header_row and
data_row_index are left unset, instead of the library’s normal default of
assuming row 0 is the header. Off by default – see the detect_header field doc.
Sourcepub fn max_row_count(self, max: u32) -> Self
pub fn max_row_count(self, max: u32) -> Self
Sets the maximum number of rows to read.
Sourcepub fn read_mode_async(self) -> Self
pub fn read_mode_async(self) -> Self
Sets the read mode to asynchronous, single sheet mode This is for reading long files with 10K+ rows in the target sheet
Sourcepub fn read_mode_preview(self) -> Self
pub fn read_mode_preview(self) -> Self
Sets the read mode to direct with multiple sheet output This serves to fetch quick a overview of a spreadsheet
Sourcepub fn set_read_mode(self, key: &str) -> Self
pub fn set_read_mode(self, key: &str) -> Self
Sets read mode from a range of common key names
async, preview or sync (default) with synonyms such as a, p and s
If the key is unmatched, it will always default to Sync
pub fn multimode(&self) -> bool
pub fn file_name(&self) -> Option<String>
Sourcepub fn override_headers(self, keys: &[&str]) -> Self
pub fn override_headers(self, keys: &[&str]) -> Self
Override matched and unmatched headers with custom headers.
Sourcepub fn override_columns(self, cols: &[Value]) -> Self
pub fn override_columns(self, cols: &[Value]) -> Self
Override matched and unmatched columns with custom keys and/or formatting options
Sourcepub fn field_name_mode(self, system: &str, override_header: bool) -> Self
pub fn field_name_mode(self, system: &str, override_header: bool) -> Self
Sets the column key naming convention.
pub fn row_mode(&self) -> String
pub fn header_mode(&self) -> String
pub fn index_list(&self) -> String
Sourcepub fn to_lines(&self) -> Vec<String>
pub fn to_lines(&self) -> Vec<String>
render option output contextually as a list of strings for use in a terminal or text output
Sourcepub fn header_row_index(&self) -> usize
pub fn header_row_index(&self) -> usize
0-based header row index, resolved without auto-detection – header_row if set,
row 0 otherwise. Detection (see detect::detect_header_and_data_rows) only runs
when both header_row and data_row_index are unset, and requires sample row data
this method doesn’t have access to; readers check for that case themselves before
falling back to this method.
Sourcepub fn first_data_row_index(&self) -> Option<usize>
pub fn first_data_row_index(&self) -> Option<usize>
0-based absolute row index at which data capture may begin, combining header_row,
data_row_index, and omit_header. None when nothing is customized (header row
0, no explicit data row) – meaning no additional gating beyond the ordinary “first
row after the header” behavior applies, so callers can skip this check entirely
rather than compute a value that changes nothing.
data_row_index is honored literally whenever it’s at or after the header row –
including equal to the header row, which is a legitimate (if rare) configuration:
a CSV with predefined/external headers where no line is actually consumed as a
header, or a sheet that inherits its column names from elsewhere and has no header
line of its own. It’s only treated as unset (falling back to the default below) when
it’s strictly before the header row, which is never meaningful.
The default when data_row_index is unset depends on whether a header row is
actually being consumed: immediately after the header row when one is (the common
case), or right at the header row itself when omit_header is set – since then no
row is being consumed for headers in the first place, so there’s nothing to skip
past.