Struct History

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

Structure encapsulating command history

Fields§

§buffers: VecDeque<Buffer>

Vector of buffers to store history in

§append_duplicate_entries: bool§inc_append: bool

Append each entry to history file as entered?

§share: bool

Share history across ion’s with the same history file (combine with inc_append).

§file_size: u64

Last filesize of history file, used to optimize history sharing.

§load_duplicates: bool

Allow loading duplicate entries, need to know this for loading history files.

Implementations§

Source§

impl History

Source

pub fn new() -> History

Create new History structure.

Source

pub fn clear_history(&mut self)

Clears out the history.

Source

pub fn load_history(&mut self, append: bool) -> Result<u64>

Loads the history file from the saved path and appends it to the end of the history if append is true otherwise replace history.

Source

pub fn load_history_file<P: AsRef<Path>>( &mut self, path: P, append: bool, ) -> Result<u64>

Loads the history file from path and appends it to the end of the history if append is true.

Source

pub fn set_file_name_and_load_history<P: AsRef<Path>>( &mut self, path: P, ) -> Result<u64>

Set history file name and at the same time load the history.

Source

pub fn set_max_buffers_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 len(&self) -> usize

Number of items in history.

Source

pub fn is_empty(&self) -> bool

Is the history empty

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 remove_duplicates(&mut self, input: &str)

Removes duplicate entries in the history

Source

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

Go through the history and try to find an index (newest to oldest) which starts the same as the new buffer given to this function as argument. Starts at curr_position. Does no wrap.

Source

pub fn get_history_subset(&self, search_term: &Buffer) -> Vec<usize>

Source

pub fn search_index(&self, search_term: &Buffer) -> Vec<usize>

Source

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

Get the history file name.

Source

pub fn commit_to_file_path<P: AsRef<Path>>(&mut self, path: P) -> Result<String>

Source

pub fn commit_to_file(&mut self)

Trait Implementations§

Source§

impl Default for History

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.