Struct intelli_shell::storage::SqliteStorage
source · pub struct SqliteStorage { /* private fields */ }
Expand description
SQLite-based storage
Implementations§
source§impl SqliteStorage
impl SqliteStorage
sourcepub fn new_in_memory() -> Result<Self>
pub fn new_in_memory() -> Result<Self>
Builds a new in-memory SQLite storage for testing purposes
sourcepub fn insert_command(&self, command: &mut Command) -> Result<bool>
pub fn insert_command(&self, command: &mut Command) -> Result<bool>
Inserts a command and updates its id
with the inserted value.
If the command already exist on the database, its description will be updated.
Returns wether the command was inserted or not (updated)
sourcepub fn insert_commands(&self, commands: &mut [Command]) -> Result<u64>
pub fn insert_commands(&self, commands: &mut [Command]) -> Result<u64>
Inserts a bunch of commands and updates its id
with the inserted value.
If any command already exist on the database, its description will be updated.
Returns the number of commands inserted (the rest are updated)
sourcepub fn update_command(&self, command: &Command) -> Result<bool>
pub fn update_command(&self, command: &Command) -> Result<bool>
Updates an existing command
Returns wether the command exists and was updated or not.
sourcepub fn increment_command_usage(&self, command_id: i64) -> Result<bool>
pub fn increment_command_usage(&self, command_id: i64) -> Result<bool>
Updates an existing command by incrementing its usage by one
Returns wether the command exists and was updated or not.
sourcepub fn delete_command(&self, command_id: i64) -> Result<bool>
pub fn delete_command(&self, command_id: i64) -> Result<bool>
Deletes an existing command
Returns wether the command exists and was deleted or not.
sourcepub fn get_commands(&self, category: impl AsRef<str>) -> Result<Vec<Command>>
pub fn get_commands(&self, category: impl AsRef<str>) -> Result<Vec<Command>>
Get commands matching a category
sourcepub fn find_commands(&self, search: impl AsRef<str>) -> Result<Vec<Command>>
pub fn find_commands(&self, search: impl AsRef<str>) -> Result<Vec<Command>>
Finds commands matching the given search criteria
sourcepub fn export(
&self,
category: impl AsRef<str>,
file_path: impl Into<String>
) -> Result<usize>
pub fn export( &self, category: impl AsRef<str>, file_path: impl Into<String> ) -> Result<usize>
Exports the commands from a given category into the given file path
Returns
The number of exported commands
sourcepub fn insert_label_suggestion(
&self,
suggestion: &LabelSuggestion
) -> Result<bool>
pub fn insert_label_suggestion( &self, suggestion: &LabelSuggestion ) -> Result<bool>
Inserts a label suggestion if it doesn’t exists.
Returns wether the suggestion was inserted or not (already existed)
sourcepub fn update_label_suggestion(
&self,
suggestion: &LabelSuggestion
) -> Result<bool>
pub fn update_label_suggestion( &self, suggestion: &LabelSuggestion ) -> Result<bool>
Updates an existing label suggestion
Returns wether the suggestion exists and was updated or not.
sourcepub fn delete_label_suggestion(
&self,
suggestion: &LabelSuggestion
) -> Result<bool>
pub fn delete_label_suggestion( &self, suggestion: &LabelSuggestion ) -> Result<bool>
Deletes an existing label suggestion
Returns wether the suggestion exists and was deleted or not.
sourcepub fn find_suggestions_for(
&self,
root_cmd: impl AsRef<str>,
label: impl AsRef<str>
) -> Result<Vec<LabelSuggestion>>
pub fn find_suggestions_for( &self, root_cmd: impl AsRef<str>, label: impl AsRef<str> ) -> Result<Vec<LabelSuggestion>>
Finds label suggestions for the given root command and label