Struct Table

Source
pub struct Table { /* private fields */ }
Expand description

Contains the data read from a csv Assumes nonzero columns and rows

Implementations§

Source§

impl Table

Source

pub fn new() -> Self

Source

pub fn from_path(path: &str) -> Self

Construct new table from the csv at the provided path.

Source

pub fn dims(&self) -> (usize, usize)

Returns the dimensions of the data within the table. Cache this value

Source

pub fn col_widths(&self) -> Vec<i32>

Calculates the max characters needed to display all values in a column. Needs rewrite to be more efficient (after removing headers) Also cache this value

Source

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

Add iterator for column widths along with row value? for (cell, width) in row.iter().zip(table.col_widths().iter()) { actually do fmt

Source

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

Gets the internal data Should be formalized as iterators

Source

pub fn get(&self, c: Cursor) -> String

Gets a value in the table.

Source

pub fn update(&mut self, c: Cursor, new: String)

Updates a value in the table.

Source

pub fn add_row_before(&mut self, c: Cursor)

Adds row before the cursor location.

Source

pub fn add_row_after(&mut self, c: Cursor)

Adds row after the cursor location.

Source

pub fn add_col_before(&mut self, c: Cursor)

Adds column before the cursor location.

Source

pub fn add_col_after(&mut self, c: Cursor)

Adds column after the cursor location.

Source

pub fn clear(&mut self, c: Cursor)

Clears the value in the table.

Source

pub fn delete_row(&mut self, c: &mut Cursor)

Deletes the row the cursor lies.

Source

pub fn delete_col(&mut self, c: &mut Cursor)

Deletes the column the cursor lies.

Source

pub fn save_to_path(&self, path: String)

Writes the data as a csv to the given path.

Trait Implementations§

Source§

impl Debug for Table

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnwindSafe for Table

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> 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, 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.