rustyline::history

Type Alias DefaultHistory

Source
pub type DefaultHistory = FileHistory;
Expand description

Default file-based history implementation

Aliased Type§

struct DefaultHistory { /* private fields */ }

Implementations

Source§

impl FileHistory

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().
Source

pub fn iter(&self) -> impl DoubleEndedIterator<Item = &String> + '_

Return a forward iterator.

Trait Implementations

Source§

impl Default for FileHistory

Source§

fn default() -> FileHistory

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

impl History for FileHistory

Source§

fn get( &self, index: usize, dir: 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. Read more
Source§

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

Add a new entry in the history. Read more
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: &Path) -> Result<()>

Save the history in the specified file.
Source§

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

Append new entries in the specified file.
Source§

fn load(&mut self, path: &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 FileHistory

Source§

type Output = String

The returned type after indexing.
Source§

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

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