pub trait History: Send {
    fn save(&mut self, h: HistoryItem) -> Result<HistoryItem, ReedlineError>;
    fn load(&self, id: HistoryItemId) -> Result<HistoryItem, ReedlineError>;
    fn count(&self, query: SearchQuery) -> Result<i64, ReedlineError>;
    fn search(
        &self,
        query: SearchQuery
    ) -> Result<Vec<HistoryItem>, ReedlineError>; fn update(
        &mut self,
        id: HistoryItemId,
        updater: &dyn Fn(HistoryItem) -> HistoryItem
    ) -> Result<(), ReedlineError>; fn delete(&mut self, h: HistoryItemId) -> Result<(), ReedlineError>; fn sync(&mut self) -> Result<()>; fn count_all(&self) -> Result<i64, ReedlineError> { ... } }
Expand description

Represents a history file or database Data could be stored e.g. in a plain text file, in a JSONL file, in a SQLite database

Required Methods

save a history item to the database if given id is None, a new id is created and set in the return value if given id is Some, the existing entry is updated

load a history item by its id

retrieves the next unused session id count the results of a query

return the results of a query

update an item atomically

remove an item from this history

ensure that this history is written to disk

Provided Methods

return the total number of history items

Implementors