[−][src]Struct rustyline::history::History
Current state of the history.
Implementations
impl History
[src]
pub fn new() -> Self
[src]
Default constructor
pub fn with_config(config: Config) -> Self
[src]
Customized constructor with:
Config::max_history_size()
,Config::history_ignore_space()
,Config::history_duplicates()
.
pub fn get(&self, index: usize) -> Option<&String>
[src]
Return the history entry at position index
, starting from 0.
pub fn last(&self) -> Option<&String>
[src]
Return the last history entry (i.e. previous command)
pub fn add<S: AsRef<str> + Into<String>>(&mut self, line: S) -> bool
[src]
Add a new entry in the history.
pub fn len(&self) -> usize
[src]
Return the number of entries in the history.
pub fn is_empty(&self) -> bool
[src]
Return true if the history has no entry.
pub fn set_max_len(&mut self, len: usize)
[src]
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.
pub fn save<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<()>
[src]
Save the history in the specified file.
pub fn append<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<()>
[src]
Append new entries in the specified file.
pub fn load<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<()>
[src]
Load the history from the specified file.
Errors
Will return Err
if path does not already exist or could not be read.
pub fn clear(&mut self)
[src]
Clear history
pub fn search(&self, term: &str, start: usize, dir: Direction) -> Option<usize>
[src]
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.
pub fn starts_with(
&self,
term: &str,
start: usize,
dir: Direction
) -> Option<usize>
[src]
&self,
term: &str,
start: usize,
dir: Direction
) -> Option<usize>
Anchored search
pub fn iter(&self) -> Iter<'_>ⓘ
[src]
Return a forward iterator.
Trait Implementations
impl Default for History
[src]
impl Index<usize> for History
[src]
type Output = String
The returned type after indexing.
pub fn index(&self, index: usize) -> &String
[src]
impl<'a> IntoIterator for &'a History
[src]
Auto Trait Implementations
impl RefUnwindSafe for History
[src]
impl Send for History
[src]
impl Sync for History
[src]
impl Unpin for History
[src]
impl UnwindSafe for History
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,