mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement add method
This commit is contained in:
parent
3613db8b1c
commit
302e1c4557
1 changed files with 10 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ mod memory;
|
|||
|
||||
use database::Database;
|
||||
use error::Error;
|
||||
use gtk::glib::Uri;
|
||||
use memory::Memory;
|
||||
use sqlite::{Connection, Transaction};
|
||||
use std::{rc::Rc, sync::RwLock};
|
||||
|
|
@ -31,6 +32,15 @@ impl Search {
|
|||
|
||||
// Actions
|
||||
|
||||
/// Add new search provider record
|
||||
/// * requires valid [Uri](https://docs.gtk.org/glib/struct.Uri.html)
|
||||
pub fn add(&self, query: Uri, is_default: bool) -> Result<(), Error> {
|
||||
match self.database.add(query.to_string(), is_default) {
|
||||
Ok(_) => Ok(index(&self.database, &self.memory)?),
|
||||
Err(e) => Err(Error::Database(e)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get records from the memory index
|
||||
pub fn records(&self) -> Vec<database::Row> {
|
||||
self.memory.records()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue