pub struct SqliteStorage { /* private fields */ }
Expand description

SQLite-based storage

Implementations§

source§

impl SqliteStorage

source

pub fn new() -> Result<Self>

Builds a new SQLite storage on the default path

source

pub fn new_in_memory() -> Result<Self>

Builds a new in-memory SQLite storage for testing purposes

source

pub fn insert_command(&mut 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)

source

pub fn insert_commands(&mut 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)

source

pub fn update_command(&mut self, command: &Command) -> Result<bool>

Updates an existing command

Returns wether the command exists and was updated or not.

source

pub fn delete_command(&mut self, command_id: i64) -> Result<bool>

Deletes an existing command

Returns wether the command exists and was updated or not.

source

pub fn get_commands(&self, category: impl AsRef<str>) -> Result<Vec<Command>>

Get commands matching a category

source

pub fn find_commands(&self, search: impl AsRef<str>) -> Result<Vec<Command>>

Finds commands matching the given search criteria

source

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

source

pub fn import( &mut 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

Trait Implementations§

source§

impl Drop for SqliteStorage

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.