Struct History

Source
pub struct History {
    pub buffers: VecDeque<Buffer>,
    pub append_duplicate_entries: bool,
    /* private fields */
}
Expand description

Structure encapsulating command history

Fields§

§buffers: VecDeque<Buffer>

Vector of buffers to store history in

§append_duplicate_entries: bool

Implementations§

Source§

impl History

Source

pub fn commit_history(&mut self)

It’s important to execute this function before exiting your program, as it will ensure that all history data has been written to the disk.

Source

pub fn new() -> History

Create new History structure.

Source

pub fn len(&self) -> usize

Number of items in history.

Source

pub fn push(&mut self, new_item: Buffer) -> Result<()>

Add a command to the history buffer and remove the oldest commands when the max history size has been met. If writing to the disk is enabled, this function will be used for logging history to the designated history file.

Source

pub fn get_newest_match<'a, 'b>( &'a self, curr_position: Option<usize>, new_buff: &'b Buffer, ) -> Option<&'a Buffer>

Go through the history and try to find a buffer which starts the same as the new buffer given to this function as argument.

Source

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

Get the history file name.

Source

pub fn set_file_name(&mut self, name: Option<String>)

Set history file name. At the same time enable history.

Source

pub fn set_max_size(&mut self, size: usize)

Set maximal number of buffers stored in memory

Source

pub fn set_max_file_size(&mut self, size: usize)

Set maximal number of entries in history file

Source

pub fn load_history(&mut self) -> Result<()>

Load history from given file name

Trait Implementations§

Source§

impl Index<usize> for History

Source§

type Output = Buffer

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Buffer

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

impl IndexMut<usize> for History

Source§

fn index_mut(&mut self, index: usize) -> &mut Buffer

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

impl<'a> IntoIterator for &'a History

Source§

type Item = &'a Buffer

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Buffer>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. 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> 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.