Skip to main content

OptionSet

Struct OptionSet 

Source
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: bool

Whether 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: FieldNameMode

Implementations§

Source§

impl OptionSet

Source

pub fn new(path_str: &str) -> Self

Instantiates a new option set with a path string for file operations.

Source

pub fn sheet_name(self, name: &str) -> Self

Sets the sheet name for the operation.

Source

pub fn sheet_names(self, names: &[String]) -> Self

Sets the sheet name for the operation.

Source

pub fn sheet_index(self, index: u32) -> Self

Sets the sheet index.

Source

pub fn sheet_indices(self, indices: &[u32]) -> Self

Sets the sheet index.

Source

pub fn json_lines(self) -> Self

Sets JSON Lines mode to true.

Source

pub fn set_json_lines(self, mode: bool) -> Self

Sets JSON Lines mode

Source

pub fn omit_header(self) -> Self

Omits the header when reading.

Source

pub fn header_row(self, row: usize) -> Self

Sets the header row’s 0-based row index.

Source

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.

Source

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.

Source

pub fn max_row_count(self, max: u32) -> Self

Sets the maximum number of rows to read.

Source

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

Source

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

Source

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

Source

pub fn multimode(&self) -> bool

Source

pub fn file_name(&self) -> Option<String>

Source

pub fn override_headers(self, keys: &[&str]) -> Self

Override matched and unmatched headers with custom headers.

Source

pub fn override_columns(self, cols: &[Value]) -> Self

Override matched and unmatched columns with custom keys and/or formatting options

Source

pub fn field_name_mode(self, system: &str, override_header: bool) -> Self

Sets the column key naming convention.

Source

pub fn row_mode(&self) -> String

Source

pub fn header_mode(&self) -> String

Source

pub fn to_json(&self) -> Value

render option output contextually as JSON

Source

pub fn index_list(&self) -> String

Source

pub fn to_lines(&self) -> Vec<String>

render option output contextually as a list of strings for use in a terminal or text output

Source

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.

Source

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.

Source

pub fn max_rows(&self) -> usize

get the maximum of rows to be output synchronously

Source

pub fn columns(&self) -> Vec<Column>

future development with advanced column options

Source

pub fn read_mode(&self) -> ReadMode

cloned read mode

Source

pub fn is_async(&self) -> bool

Needs full data set to processed later

Source

pub fn capture_rows(&self) -> bool

Trait Implementations§

Source§

impl Clone for OptionSet

Source§

fn clone(&self) -> OptionSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OptionSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OptionSet

Source§

fn default() -> OptionSet

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.