pub struct Row {
pub values: HashMap<String, Value>,
}Expand description
Row
Row is implementated as a hashmap. You cannot iterate row without column information.
Fields§
§values: HashMap<String, Value>Implementations§
Source§impl Row
impl Row
Sourcepub fn to_vector(&self, columns: &[Column]) -> DcsvResult<Vec<&Value>>
pub fn to_vector(&self, columns: &[Column]) -> DcsvResult<Vec<&Value>>
Convert row to vector with given columns
It is totally valid to give partial columns into a row.
Sourcepub fn to_string(&self, columns: &[Column]) -> DcsvResult<String>
pub fn to_string(&self, columns: &[Column]) -> DcsvResult<String>
Get comma separated row string
This requires columns because a row is not a linear container. Partial column is not an error but valid behaviour.
Sourcepub fn rename_column(&mut self, name: &str, new_name: &str)
pub fn rename_column(&mut self, name: &str, new_name: &str)
Rename column name inside row map
This doesn’t validate column’s name and should comply with column name rule to avoid unintended behaviour.
Sourcepub fn insert_cell(&mut self, key: &str, value: Value)
pub fn insert_cell(&mut self, key: &str, value: Value)
Insert a new cell(key, value pair) into a row
Sourcepub fn get_cell_value(&self, key: &str) -> Option<&Value>
pub fn get_cell_value(&self, key: &str) -> Option<&Value>
Get a cell value by a key
Sourcepub fn update_cell_value(&mut self, key: &str, value: Value)
pub fn update_cell_value(&mut self, key: &str, value: Value)
Update a cell’s value with a given value
This doesn’t fail and silently do nothing if key doesn’t exist.
Sourcepub fn change_cell_type(
&mut self,
key: &str,
target_type: ValueType,
) -> DcsvResult<()>
pub fn change_cell_type( &mut self, key: &str, target_type: ValueType, ) -> DcsvResult<()>
Chagnes a cell’s value type
This method tries to naturally convert cell’s type. Empty text value defaults to “0”.
Sourcepub fn remove_cell(&mut self, key: &str)
pub fn remove_cell(&mut self, key: &str)
Remove a cell by key
Sourcepub fn get_iterator(&self, columns: &[Column]) -> IntoIter<&Value>
pub fn get_iterator(&self, columns: &[Column]) -> IntoIter<&Value>
Get iterator with given columns