pub struct MemHistory { /* private fields */ }
Expand description

Transient in-memory history implementation.

Implementations§

source§

impl MemHistory

source

pub fn new() -> Self

Default constructor

source

pub fn with_config(config: Config) -> Self

Customized constructor with:

  • Config::max_history_size(),
  • Config::history_ignore_space(),
  • Config::history_duplicates().

Trait Implementations§

source§

impl Default for MemHistory

source§

fn default() -> Self

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

impl History for MemHistory

source§

fn get( &self, index: usize, _: SearchDirection ) -> Result<Option<SearchResult<'_>>>

Return the history entry at position index, starting from 0. Read more
source§

fn add(&mut self, line: &str) -> Result<bool>

Add a new entry in the history.
source§

fn add_owned(&mut self, line: String) -> Result<bool>

Add a new entry in the history.
source§

fn len(&self) -> usize

Return the number of entries in the history.
source§

fn is_empty(&self) -> bool

Return true if the history has no entry.
source§

fn set_max_len(&mut self, len: usize) -> Result<()>

Set the maximum length for the history. This function can be called even if there is already some history, the function will make sure to retain just the latest len elements if the new history length value is smaller than the amount of items already inside the history. Read more
source§

fn ignore_dups(&mut self, yes: bool) -> Result<()>

Ignore consecutive duplicates
source§

fn ignore_space(&mut self, yes: bool)

Ignore lines which begin with a space or not
source§

fn save(&mut self, _: &Path) -> Result<()>

Save the history in the specified file.
source§

fn append(&mut self, _: &Path) -> Result<()>

Append new entries in the specified file.
source§

fn load(&mut self, _: &Path) -> Result<()>

Load the history from the specified file. Read more
source§

fn clear(&mut self) -> Result<()>

Clear in-memory history
source§

fn search( &self, term: &str, start: usize, dir: SearchDirection ) -> Result<Option<SearchResult<'_>>>

Search history (start position inclusive [0, len-1]). Read more
source§

fn starts_with( &self, term: &str, start: usize, dir: SearchDirection ) -> Result<Option<SearchResult<'_>>>

Anchored search
source§

impl Index<usize> for MemHistory

§

type Output = String

The returned type after indexing.
source§

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

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

impl<'a> IntoIterator for &'a MemHistory

§

type IntoIter = Iter<'a, String>

Which kind of iterator are we turning this into?
§

type Item = &'a String

The type of the elements being iterated over.
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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.