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 import(
&self,
category: impl AsRef<str>,
file_path: String,
) -> Result<u64>
pub fn import( &self, category: impl AsRef<str>, file_path: String, ) -> Result<u64>
Imports commands from the given file into a category.
§Returns
The number of newly inserted 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: &mut LabelSuggestion,
new_suggestion: impl Into<String>,
) -> Result<bool>
pub fn update_label_suggestion( &self, suggestion: &mut LabelSuggestion, new_suggestion: impl Into<String>, ) -> Result<bool>
Updates an existing label suggestion
Returns wether the suggestion exists and was updated or not.
Sourcepub fn update_label_suggestion_usage(
&self,
suggestion: &LabelSuggestion,
) -> Result<bool>
pub fn update_label_suggestion_usage( &self, suggestion: &LabelSuggestion, ) -> Result<bool>
Updates the usage of 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
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SqliteStorage
impl RefUnwindSafe for SqliteStorage
impl Send for SqliteStorage
impl Sync for SqliteStorage
impl Unpin for SqliteStorage
impl UnwindSafe for SqliteStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more