Trait rustyline::history::History

source ·
pub trait History {
Show 14 methods // Required methods fn get( &self, index: usize, dir: SearchDirection, ) -> Result<Option<SearchResult<'_>>>; fn add(&mut self, line: &str) -> Result<bool>; fn add_owned(&mut self, line: String) -> Result<bool>; fn len(&self) -> usize; fn is_empty(&self) -> bool; fn set_max_len(&mut self, len: usize) -> Result<()>; fn ignore_dups(&mut self, yes: bool) -> Result<()>; fn ignore_space(&mut self, yes: bool); fn save(&mut self, path: &Path) -> Result<()>; fn append(&mut self, path: &Path) -> Result<()>; fn load(&mut self, path: &Path) -> Result<()>; fn clear(&mut self) -> Result<()>; fn search( &self, term: &str, start: usize, dir: SearchDirection, ) -> Result<Option<SearchResult<'_>>>; fn starts_with( &self, term: &str, start: usize, dir: SearchDirection, ) -> Result<Option<SearchResult<'_>>>;
}
Expand description

Interface for navigating/loading/storing history

Required Methods§

source

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

Return the history entry at position index, starting from 0.

SearchDirection is useful only for implementations without direct indexing.

source

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

Add a new entry in the history.

Return false if the line has been ignored (blank line / duplicate / …).

source

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

Add a new entry in the history.

Return false if the line has been ignored (blank line / duplicate / …).

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.

Like stifle_history.

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.

§Errors

Will return Err if path does not already exist or could not be read.

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]).

Return the absolute index of the nearest history entry that matches term.

Return None if no entry contains term between [start, len -1] for forward search or between [0, start] for reverse search.

source

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

Anchored search

Implementors§