papergrid::records::vec_records

Struct VecRecords

Source
pub struct VecRecords<T> { /* private fields */ }
Expand description

The structure represents a Records implementation as an pre built vector of cells.

Implementations§

Source§

impl<'a> VecRecords<CellInfo<'a>>

Source

pub fn new<R, C, T, W>(records: R, size: (usize, usize), width_ctrl: W) -> Self
where R: IntoIterator<Item = C> + 'a, C: IntoIterator<Item = T> + 'a, T: AsRef<str> + 'a, W: WidthFunc,

Builds a structure instance from an iterator.

Source§

impl<T> VecRecords<T>

Source

pub fn with_hint(records: Vec<Vec<T>>, count_columns: usize) -> Self

Builds a structure instance with using an exact columns length.

WARNING: You must verify that provided records contains is bigger than or eqaull than provided hint value.

Source

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

Returns a shape of Records.

Source

pub fn count_rows(&self) -> usize

Returns a count of rows.

Source

pub fn count_columns(&self) -> usize

Returns a count of columns.

Source

pub fn truncate(&mut self, len: usize)

Truncates columns to the given length.

Source§

impl<T> VecRecords<T>
where T: Clone,

Source

pub fn push(&mut self, cell: T)

Creates a column with a given cell.

The cell will be cloned.

Source§

impl<T> VecRecords<T>
where T: Clone,

Source

pub fn duplicate_row(&mut self, row: usize)

Takes a row index and pushes the cloned row to the end.

Trait Implementations§

Source§

impl<T: Clone> Clone for VecRecords<T>

Source§

fn clone(&self) -> VecRecords<T>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for VecRecords<T>

Source§

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

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

impl<T: Default> Default for VecRecords<T>

Source§

fn default() -> VecRecords<T>

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

impl<T> From<Vec<Vec<T>>> for VecRecords<T>

Source§

fn from(records: Vec<Vec<T>>) -> Self

Converts to this type from the input type.
Source§

impl<T> Index<(usize, usize)> for VecRecords<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, (row, col): Position) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<(usize, usize)> for VecRecords<T>

Source§

fn index_mut(&mut self, (row, col): Position) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> Records for VecRecords<T>
where T: Cell,

Source§

fn count_rows(&self) -> usize

Returns amount of rows on a grid.
Source§

fn count_columns(&self) -> usize

Returns amount of columns on a grid.
Source§

fn get_text(&self, (row, col): Position) -> &str

Returns a text of a cell by an index.
Source§

fn get_line(&self, (row, col): Position, i: usize) -> &str

Returns a line of a text of a cell by an index.
Source§

fn get_width<W>(&self, (row, col): Position, width_ctrl: W) -> usize
where W: WidthFunc,

Returns a width of a text of a cell by an index.
Source§

fn get_line_width<W>( &self, (row, col): Position, i: usize, width_ctrl: W, ) -> usize
where W: WidthFunc,

Returns a width of line of a text of a cell by an index.
Source§

fn count_lines(&self, (row, col): Position) -> usize

Returns an amount of lines of a text of a cell by an index.
Source§

fn fmt_text_prefix(&self, f: &mut Formatter<'_>, (row, col): Position) -> Result

Prints a prefix of a text of a cell by an index. Read more
Source§

fn fmt_text_suffix(&self, f: &mut Formatter<'_>, (row, col): Position) -> Result

Prints a suffix of a text of a cell by an index. Read more
Source§

impl<T, Q> RecordsMut<Q> for VecRecords<T>
where T: CellMut<Q>,

Source§

fn set<W>(&mut self, (row, col): Position, text: Q, width_ctrl: W)
where W: WidthFunc,

Sets a text to a given cell by index.
Source§

fn update<W>(&mut self, (row, col): Position, width_ctrl: W)
where W: WidthFunc,

Updates a given cell by index. Read more
Source§

impl<T> Resizable for VecRecords<T>
where T: Default + Clone,

Source§

fn swap(&mut self, lhs: Position, rhs: Position)

Swap cells with one another.
Source§

fn swap_row(&mut self, lhs: usize, rhs: usize)

Swap rows with one another.
Source§

fn swap_column(&mut self, lhs: usize, rhs: usize)

Swap columns with one another.
Source§

fn push_row(&mut self)

Adds a new row to a data set.
Source§

fn push_column(&mut self)

Adds a new column to a data set.
Source§

fn remove_row(&mut self, row: usize)

Removes a row from a data set by index.
Source§

fn remove_column(&mut self, column: usize)

Removes a column from a data set by index.
Source§

fn insert_row(&mut self, row: usize)

Inserts a row to specific by row index.

Auto Trait Implementations§

§

impl<T> Freeze for VecRecords<T>

§

impl<T> RefUnwindSafe for VecRecords<T>
where T: RefUnwindSafe,

§

impl<T> Send for VecRecords<T>
where T: Send,

§

impl<T> Sync for VecRecords<T>
where T: Sync,

§

impl<T> Unpin for VecRecords<T>
where T: Unpin,

§

impl<T> UnwindSafe for VecRecords<T>
where T: UnwindSafe,

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.