From 302e1c455763ee2f565d06704cc929a8634a2478 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 30 Jan 2025 13:18:58 +0200 Subject: [PATCH] implement `add` method --- src/profile/search.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/profile/search.rs b/src/profile/search.rs index 777ccb18..e0d72c61 100644 --- a/src/profile/search.rs +++ b/src/profile/search.rs @@ -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 { self.memory.records()