pub struct Database { /* private fields */ }
Expand description
The main database interface for command-vault.
Handles all database operations including:
- Command storage and retrieval
- Tag management
- Search functionality
§Example
use anyhow::Result;
use command_vault::db::Database;
fn main() -> Result<()> {
let db = Database::new("commands.db")?;
db.init()?;
Ok(())
}
Implementations§
Source§impl Database
impl Database
Sourcepub fn init(&self) -> Result<()>
pub fn init(&self) -> Result<()>
Initializes the database schema.
Creates the following tables if they don’t exist:
- commands: Stores command information
- tags: Stores tag information
- command_tags: Links commands to tags
Sourcepub fn add_command(&mut self, command: &Command) -> Result<i64>
pub fn add_command(&mut self, command: &Command) -> Result<i64>
Lists all tags in the database.
§Returns
Result<Vec<(String, i64)>>
- A list of tags with their respective counts
Sourcepub fn update_command(&mut self, command: &Command) -> Result<()>
pub fn update_command(&mut self, command: &Command) -> Result<()>
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl !Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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