pub struct Processor { /* private fields */ }
Expand description
Csv processor
Processor has multiple pages which can be accessed with page_name. Processor has currently
selected page which name can be accessed with get_cursor
method.
Implementations
sourceimpl Processor
impl Processor
sourcepub fn change_cursor(&mut self, page_name: &str) -> bool
pub fn change_cursor(&mut self, page_name: &str) -> bool
Change current cusor(page)
This doesn’t affect page itself but change cursor.
- This returns boolean value whether change succeeded or not
sourcepub fn get_cursor(&self) -> Option<String>
pub fn get_cursor(&self) -> Option<String>
Get current cursor (page_name)
sourcepub fn add_page(
&mut self,
page: &str,
data: &str,
has_header: bool,
line_ending: Option<char>,
raw_mode: bool
) -> CedResult<()>
pub fn add_page(
&mut self,
page: &str,
data: &str,
has_header: bool,
line_ending: Option<char>,
raw_mode: bool
) -> CedResult<()>
Add a new page
Args
- page : Page name to create
- data : Csv data to store inside a page
- has_header : Whether csv data has header or not.
- line_ending : Optional line_ending configuration.
- raw_mode : This decides whether page be data or array
sourcepub fn remove_page(&mut self, page_name: &str)
pub fn remove_page(&mut self, page_name: &str)
Remove page with given name
This doesn’t panic and silent do nothing if page name is non-existent
sourcepub fn contains_page(&self, page: &str) -> bool
pub fn contains_page(&self, page: &str) -> bool
Check if processor contains a page
sourcepub fn drop_pages(&mut self) -> CedResult<()>
pub fn drop_pages(&mut self) -> CedResult<()>
Drop all data from processor
sourcepub fn import_from_file(
&mut self,
path: impl AsRef<Path>,
has_header: bool,
line_ending: Option<char>,
raw_mode: bool
) -> CedResult<()>
pub fn import_from_file(
&mut self,
path: impl AsRef<Path>,
has_header: bool,
line_ending: Option<char>,
raw_mode: bool
) -> CedResult<()>
Import file content as page
This will drop the page if given page name already exists.
Args
- path: File path to import from
- has_header : Whether csv file has header or not
- line_ending : Optional line_ending of csv
- raw_mode : Whether imported as data or array
sourcepub fn write_to_file(&self, page: &str, file: impl AsRef<Path>) -> CedResult<()>
pub fn write_to_file(&self, page: &str, file: impl AsRef<Path>) -> CedResult<()>
Write all page’s content into a file
sourcepub fn overwrite_to_file(&self, page: &str, cache: bool) -> CedResult<bool>
pub fn overwrite_to_file(&self, page: &str, cache: bool) -> CedResult<bool>
Overwrite virtual data’s content into a imported file
- cache : whether to backup original file’s content into temp directory
sourcepub fn edit_cell(
&mut self,
page: &str,
x: usize,
y: usize,
input: &str
) -> CedResult<()>
pub fn edit_cell(
&mut self,
page: &str,
x: usize,
y: usize,
input: &str
) -> CedResult<()>
Edit a cell by given coordinate
sourcepub fn edit_column(
&mut self,
page: &str,
column: &str,
input: &str
) -> CedResult<()>
pub fn edit_column(
&mut self,
page: &str,
column: &str,
input: &str
) -> CedResult<()>
Edit a column by given coordinate
This overwrite all column values with given input
sourcepub fn edit_row(
&mut self,
page: &str,
row_index: usize,
input: &[Option<Value>]
) -> CedResult<()>
pub fn edit_row(
&mut self,
page: &str,
row_index: usize,
input: &[Option<Value>]
) -> CedResult<()>
Edit a row with values
This assumes given input accords with order of a target record.
Args
- page : Page name
- row_index : Target row
- input : Inputs are array of options. Some will overwrite and none will not.
sourcepub fn set_row(
&mut self,
page: &str,
row_index: usize,
input: &[Value]
) -> CedResult<()>
pub fn set_row(
&mut self,
page: &str,
row_index: usize,
input: &[Value]
) -> CedResult<()>
Set a row with given values
This assumes given input accords with order of a target record. This method overwrite an entire row with given values.
sourcepub fn set_row_from_string_array(
&mut self,
page: &str,
row_index: usize,
input: &[impl AsRef<str>]
) -> CedResult<()>
pub fn set_row_from_string_array(
&mut self,
page: &str,
row_index: usize,
input: &[impl AsRef<str>]
) -> CedResult<()>
Set a row with given string array
This assumes given input accords with order of a target record. This method overwrite an entire row with given values.
sourcepub fn add_row(
&mut self,
page: &str,
row_index: usize,
values: Option<&[Value]>
) -> CedResult<()>
pub fn add_row(
&mut self,
page: &str,
row_index: usize,
values: Option<&[Value]>
) -> CedResult<()>
Add a new row
This assumes given input accords with order of a target record.
Args
- page: Target page
- row_index : Target row
- values : Option. “None” will converted as default values.
sourcepub fn add_row_from_string_array(
&mut self,
page: &str,
row_index: usize,
src: &[impl AsRef<str>]
) -> CedResult<()>
pub fn add_row_from_string_array(
&mut self,
page: &str,
row_index: usize,
src: &[impl AsRef<str>]
) -> CedResult<()>
Add a new row but from array of strings
This assumes given input accords with order of a target record.
Args
- page: Target page
- row_index : Target row
- values : Option. “None” will converted as default values.
sourcepub fn add_column(
&mut self,
page: &str,
column_index: usize,
column_name: &str,
column_type: ValueType,
limiter: Option<ValueLimiter>,
placeholder: Option<Value>
) -> CedResult<()>
pub fn add_column(
&mut self,
page: &str,
column_index: usize,
column_name: &str,
column_type: ValueType,
limiter: Option<ValueLimiter>,
placeholder: Option<Value>
) -> CedResult<()>
Add a new column into a page
sourcepub fn remove_row(&mut self, page: &str, row_index: usize) -> CedResult<bool>
pub fn remove_row(&mut self, page: &str, row_index: usize) -> CedResult<bool>
Remove a row from a page
sourcepub fn remove_column(
&mut self,
page: &str,
column_index: usize
) -> CedResult<()>
pub fn remove_column(
&mut self,
page: &str,
column_index: usize
) -> CedResult<()>
Remove a column from a page
sourcepub fn add_column_array(
&mut self,
page: &str,
columns: &[impl AsRef<str>]
) -> CedResult<()>
pub fn add_column_array(
&mut self,
page: &str,
columns: &[impl AsRef<str>]
) -> CedResult<()>
Add columns into a page
This method dosn’t require any column configurators
sourcepub fn move_row(
&mut self,
page: &str,
src: usize,
target: usize
) -> CedResult<()>
pub fn move_row(
&mut self,
page: &str,
src: usize,
target: usize
) -> CedResult<()>
Move a rom from an index to a target index
sourcepub fn move_column(
&mut self,
page: &str,
src: usize,
target: usize
) -> CedResult<()>
pub fn move_column(
&mut self,
page: &str,
src: usize,
target: usize
) -> CedResult<()>
Move a column from an index to a target index
sourcepub fn rename_column(
&mut self,
page: &str,
column: &str,
new_name: &str
) -> CedResult<()>
pub fn rename_column(
&mut self,
page: &str,
column: &str,
new_name: &str
) -> CedResult<()>
Rename a column into a new name
sourcepub fn export_schema(&self, page: &str) -> CedResult<String>
pub fn export_schema(&self, page: &str) -> CedResult<String>
Export page’s schema
sourcepub fn set_schema(
&mut self,
page: &str,
path: impl AsRef<Path>,
panic: bool
) -> CedResult<()>
pub fn set_schema(
&mut self,
page: &str,
path: impl AsRef<Path>,
panic: bool
) -> CedResult<()>
Apply schema into a given page
Args
- page : Page name
- path : Schema file path
- panic : Whether to panic if current value fails to qualify schema. If not every unqualified values are overwritten to default qualifying values.
sourcepub fn set_limiter(
&mut self,
page: &str,
column: &str,
limiter: &ValueLimiter,
panic: bool
) -> CedResult<()>
pub fn set_limiter(
&mut self,
page: &str,
column: &str,
limiter: &ValueLimiter,
panic: bool
) -> CedResult<()>
Set a limiter to a column
Args
- page : Page name
- column : Target column name(index)
- limiter : A limiter to apply to column
- panic : Whether to panic if current value fails to qualify liimter. If not, every unqualified values are overwritten to default qualifying values.
pub fn get_row_count(&self, page: &str) -> CedResult<usize>
pub fn get_column_count(&self, page: &str) -> CedResult<usize>
sourcepub fn last_row_index(&self, page: &str) -> CedResult<usize>
pub fn last_row_index(&self, page: &str) -> CedResult<usize>
Get last row index
sourcepub fn last_column_index(&self, page: &str) -> CedResult<usize>
pub fn last_column_index(&self, page: &str) -> CedResult<usize>
Get last column index
sourcepub fn get_page_as_string(&self, page: &str) -> CedResult<String>
pub fn get_page_as_string(&self, page: &str) -> CedResult<String>
Get virtual data as string form
sourcepub fn get_cell(
&self,
page: &str,
row_index: usize,
column_index: usize
) -> CedResult<Option<&Value>>
pub fn get_cell(
&self,
page: &str,
row_index: usize,
column_index: usize
) -> CedResult<Option<&Value>>
Get cell from page
This fails when page or coordinate doesn’t exist
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Processor
impl Send for Processor
impl Sync for Processor
impl Unpin for Processor
impl UnwindSafe for Processor
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more