[niepce/gtk4] libraryclient: the client no longer need mut



commit 9adecbdfbd6813229f8cc16622ae4713a1b5bb09
Author: Hubert Figuière <hub figuiere net>
Date:   Mon May 9 00:26:18 2022 -0400

    libraryclient: the client no longer need mut
    
    - use mpsc::channel instead of a vec dequeue for ops.

 niepce-main/src/libraryclient.rs                 | 103 +++++++++++------------
 niepce-main/src/libraryclient/clientimpl.rs      |  84 +++++++-----------
 niepce-main/src/libraryclient/clientinterface.rs |  42 ++++-----
 3 files changed, 104 insertions(+), 125 deletions(-)
---
diff --git a/niepce-main/src/libraryclient.rs b/niepce-main/src/libraryclient.rs
index e265e42..ff4119a 100644
--- a/niepce-main/src/libraryclient.rs
+++ b/niepce-main/src/libraryclient.rs
@@ -24,6 +24,7 @@ pub use self::clientinterface::{ClientInterface, ClientInterfaceSync};
 
 use libc::{c_char, c_void};
 use std::ffi::CStr;
+use std::ops::Deref;
 use std::path::PathBuf;
 use std::sync::Arc;
 
@@ -39,10 +40,18 @@ use npc_fwk::utils::files::FileList;
 
 /// Wrap the libclient Arc so that it can be passed around
 /// Used in the ffi for example.
+/// Implement `Deref` to `LibraryClient`
 pub struct LibraryClientWrapper {
     client: Arc<LibraryClient>,
 }
 
+impl Deref for LibraryClientWrapper {
+    type Target = LibraryClient;
+    fn deref(&self) -> &Self::Target {
+        self.client.deref()
+    }
+}
+
 impl LibraryClientWrapper {
     pub fn new(
         dir: PathBuf,
@@ -62,7 +71,7 @@ impl LibraryClientWrapper {
     /// XXX we need to unsure this is thread safe.
     /// Don't hold this reference more than you need.
     #[inline]
-    pub fn unwrap_mut(&mut self) -> &mut LibraryClient {
+    fn unwrap_mut(&mut self) -> &mut LibraryClient {
         Arc::get_mut(&mut self.client).unwrap()
     }
 }
@@ -92,87 +101,87 @@ impl LibraryClient {
 
 impl ClientInterface for LibraryClient {
     /// get all the keywords
-    fn get_all_keywords(&mut self) {
+    fn get_all_keywords(&self) {
         self.pimpl.get_all_keywords();
     }
-    fn query_keyword_content(&mut self, id: LibraryId) {
+    fn query_keyword_content(&self, id: LibraryId) {
         self.pimpl.query_keyword_content(id);
     }
-    fn count_keyword(&mut self, id: LibraryId) {
+    fn count_keyword(&self, id: LibraryId) {
         self.pimpl.count_keyword(id);
     }
 
     /// get all the folder
-    fn get_all_folders(&mut self) {
+    fn get_all_folders(&self) {
         self.pimpl.get_all_folders();
     }
-    fn query_folder_content(&mut self, id: LibraryId) {
+    fn query_folder_content(&self, id: LibraryId) {
         self.pimpl.query_folder_content(id);
     }
-    fn count_folder(&mut self, id: LibraryId) {
+    fn count_folder(&self, id: LibraryId) {
         self.pimpl.count_folder(id);
     }
 
-    fn create_folder(&mut self, name: String, path: Option<String>) {
+    fn create_folder(&self, name: String, path: Option<String>) {
         self.pimpl.create_folder(name, path);
     }
 
-    fn delete_folder(&mut self, id: LibraryId) {
+    fn delete_folder(&self, id: LibraryId) {
         self.pimpl.delete_folder(id);
     }
 
-    fn request_metadata(&mut self, id: LibraryId) {
+    fn request_metadata(&self, id: LibraryId) {
         self.pimpl.request_metadata(id);
     }
     /// set the metadata
-    fn set_metadata(&mut self, id: LibraryId, meta: Np, value: &PropertyValue) {
+    fn set_metadata(&self, id: LibraryId, meta: Np, value: &PropertyValue) {
         self.pimpl.set_metadata(id, meta, value);
     }
-    fn write_metadata(&mut self, id: LibraryId) {
+    fn write_metadata(&self, id: LibraryId) {
         self.pimpl.write_metadata(id);
     }
 
-    fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId, to: LibraryId) {
+    fn move_file_to_folder(&self, file_id: LibraryId, from: LibraryId, to: LibraryId) {
         self.pimpl.move_file_to_folder(file_id, from, to);
     }
     /// get all the labels
-    fn get_all_labels(&mut self) {
+    fn get_all_labels(&self) {
         self.pimpl.get_all_labels();
     }
-    fn create_label(&mut self, label: String, colour: String) {
+    fn create_label(&self, label: String, colour: String) {
         self.pimpl.create_label(label, colour);
     }
-    fn delete_label(&mut self, id: LibraryId) {
+    fn delete_label(&self, id: LibraryId) {
         self.pimpl.delete_label(id);
     }
     /// update a label
-    fn update_label(&mut self, id: LibraryId, new_name: String, new_colour: String) {
+    fn update_label(&self, id: LibraryId, new_name: String, new_colour: String) {
         self.pimpl.update_label(id, new_name, new_colour);
     }
 
     /// tell to process the Xmp update Queue
-    fn process_xmp_update_queue(&mut self, write_xmp: bool) {
+    fn process_xmp_update_queue(&self, write_xmp: bool) {
         self.pimpl.process_xmp_update_queue(write_xmp);
     }
 
     /// Import files from a directory
     /// @param dir the directory
     /// @param manage true if imports have to be managed
-    fn import_files(&mut self, dir: String, files: Vec<PathBuf>, manage: Managed) {
+    fn import_files(&self, dir: String, files: Vec<PathBuf>, manage: Managed) {
         self.pimpl.import_files(dir, files, manage);
     }
 }
 
 impl ClientInterfaceSync for LibraryClient {
-    fn create_keyword_sync(&mut self, keyword: String) -> LibraryId {
+    fn create_keyword_sync(&self, keyword: String) -> LibraryId {
         self.pimpl.create_keyword_sync(keyword)
     }
 
-    fn create_label_sync(&mut self, name: String, colour: String) -> LibraryId {
+    fn create_label_sync(&self, name: String, colour: String) -> LibraryId {
         self.pimpl.create_label_sync(name, colour)
     }
 
-    fn create_folder_sync(&mut self, name: String, path: Option<String>) -> LibraryId {
+    fn create_folder_sync(&self, name: String, path: Option<String>) -> LibraryId {
         self.pimpl.create_folder_sync(name, path)
     }
 }
@@ -224,17 +233,17 @@ pub extern "C" fn libraryclient_set_trash_id(client: &mut LibraryClientWrapper,
 
 #[no_mangle]
 pub extern "C" fn libraryclient_get_trash_id(client: &mut LibraryClientWrapper) -> LibraryId {
-    client.unwrap_mut().get_trash_id()
+    client.get_trash_id()
 }
 
 #[no_mangle]
 pub extern "C" fn libraryclient_get_all_keywords(client: &mut LibraryClientWrapper) {
-    client.unwrap_mut().get_all_keywords();
+    client.get_all_keywords();
 }
 
 #[no_mangle]
 pub extern "C" fn libraryclient_get_all_folders(client: &mut LibraryClientWrapper) {
-    client.unwrap_mut().get_all_folders();
+    client.get_all_folders();
 }
 
 #[no_mangle]
@@ -242,7 +251,7 @@ pub extern "C" fn libraryclient_query_folder_content(
     client: &mut LibraryClientWrapper,
     folder_id: LibraryId,
 ) {
-    client.unwrap_mut().query_folder_content(folder_id);
+    client.query_folder_content(folder_id);
 }
 
 #[no_mangle]
@@ -257,12 +266,12 @@ pub unsafe extern "C" fn libraryclient_create_folder_sync(
     } else {
         Some(String::from(CStr::from_ptr(p).to_string_lossy()))
     };
-    client.unwrap_mut().create_folder_sync(name, path)
+    client.create_folder_sync(name, path)
 }
 
 #[no_mangle]
 pub extern "C" fn libraryclient_delete_folder(client: &mut LibraryClientWrapper, id: LibraryId) {
-    client.unwrap_mut().delete_folder(id);
+    client.delete_folder(id);
 }
 
 #[no_mangle]
@@ -270,7 +279,7 @@ pub extern "C" fn libraryclient_count_folder(
     client: &mut LibraryClientWrapper,
     folder_id: LibraryId,
 ) {
-    client.unwrap_mut().count_folder(folder_id);
+    client.count_folder(folder_id);
 }
 
 #[no_mangle]
@@ -278,12 +287,12 @@ pub extern "C" fn libraryclient_query_keyword_content(
     client: &mut LibraryClientWrapper,
     keyword_id: LibraryId,
 ) {
-    client.unwrap_mut().query_keyword_content(keyword_id);
+    client.query_keyword_content(keyword_id);
 }
 
 #[no_mangle]
 pub extern "C" fn libraryclient_count_keyword(client: &mut LibraryClientWrapper, id: LibraryId) {
-    client.unwrap_mut().count_keyword(id);
+    client.count_keyword(id);
 }
 
 #[no_mangle]
@@ -291,7 +300,7 @@ pub extern "C" fn libraryclient_request_metadata(
     client: &mut LibraryClientWrapper,
     file_id: LibraryId,
 ) {
-    client.unwrap_mut().request_metadata(file_id);
+    client.request_metadata(file_id);
 }
 
 #[no_mangle]
@@ -301,9 +310,7 @@ pub extern "C" fn libraryclient_set_metadata(
     meta: NiepcePropertyIdx,
     value: &PropertyValue,
 ) {
-    client
-        .unwrap_mut()
-        .set_metadata(file_id, NiepceProperties::Index(meta), value);
+    client.set_metadata(file_id, NiepceProperties::Index(meta), value);
 }
 
 #[no_mangle]
@@ -311,7 +318,7 @@ pub extern "C" fn libraryclient_write_metadata(
     client: &mut LibraryClientWrapper,
     file_id: LibraryId,
 ) {
-    client.unwrap_mut().write_metadata(file_id);
+    client.write_metadata(file_id);
 }
 
 #[no_mangle]
@@ -321,12 +328,12 @@ pub extern "C" fn libraryclient_move_file_to_folder(
     from: LibraryId,
     to: LibraryId,
 ) {
-    client.unwrap_mut().move_file_to_folder(file_id, from, to);
+    client.move_file_to_folder(file_id, from, to);
 }
 
 #[no_mangle]
 pub extern "C" fn libraryclient_get_all_labels(client: &mut LibraryClientWrapper) {
-    client.unwrap_mut().get_all_labels();
+    client.get_all_labels();
 }
 
 #[no_mangle]
@@ -337,9 +344,7 @@ pub unsafe extern "C" fn libraryclient_create_label(
 ) {
     let name = CStr::from_ptr(s).to_string_lossy();
     let colour = CStr::from_ptr(c).to_string_lossy();
-    client
-        .unwrap_mut()
-        .create_label(String::from(name), String::from(colour));
+    client.create_label(String::from(name), String::from(colour));
 }
 
 #[no_mangle]
@@ -350,9 +355,7 @@ pub unsafe extern "C" fn libraryclient_create_label_sync(
 ) -> LibraryId {
     let name = CStr::from_ptr(s).to_string_lossy();
     let colour = CStr::from_ptr(c).to_string_lossy();
-    client
-        .unwrap_mut()
-        .create_label_sync(String::from(name), String::from(colour))
+    client.create_label_sync(String::from(name), String::from(colour))
 }
 
 #[no_mangle]
@@ -360,7 +363,7 @@ pub extern "C" fn libraryclient_delete_label(
     client: &mut LibraryClientWrapper,
     label_id: LibraryId,
 ) {
-    client.unwrap_mut().delete_label(label_id);
+    client.delete_label(label_id);
 }
 
 #[no_mangle]
@@ -372,9 +375,7 @@ pub unsafe extern "C" fn libraryclient_update_label(
 ) {
     let name = CStr::from_ptr(s).to_string_lossy();
     let colour = CStr::from_ptr(c).to_string_lossy();
-    client
-        .unwrap_mut()
-        .update_label(label_id, String::from(name), String::from(colour));
+    client.update_label(label_id, String::from(name), String::from(colour));
 }
 
 #[no_mangle]
@@ -382,7 +383,7 @@ pub extern "C" fn libraryclient_process_xmp_update_queue(
     client: &mut LibraryClientWrapper,
     write_xmp: bool,
 ) {
-    client.unwrap_mut().process_xmp_update_queue(write_xmp);
+    client.process_xmp_update_queue(write_xmp);
 }
 
 #[no_mangle]
@@ -393,7 +394,5 @@ pub unsafe extern "C" fn libraryclient_import_files(
     manage: Managed,
 ) {
     let folder = CStr::from_ptr(dir).to_string_lossy();
-    client
-        .unwrap_mut()
-        .import_files(String::from(folder), files.0.clone(), manage);
+    client.import_files(String::from(folder), files.0.clone(), manage);
 }
diff --git a/niepce-main/src/libraryclient/clientimpl.rs b/niepce-main/src/libraryclient/clientimpl.rs
index 15e33c9..b116109 100644
--- a/niepce-main/src/libraryclient/clientimpl.rs
+++ b/niepce-main/src/libraryclient/clientimpl.rs
@@ -1,7 +1,7 @@
 /*
  * niepce - libraryclient/clientimpl.rs
  *
- * Copyright (C) 2017-2021 Hubert Figuière
+ * Copyright (C) 2017-2022 Hubert Figuière
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,7 +17,6 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-use std::collections::VecDeque;
 use std::path::PathBuf;
 use std::sync;
 use std::sync::atomic;
@@ -32,11 +31,11 @@ use npc_engine::library::commands;
 use npc_engine::library::notification::LibNotification;
 use npc_engine::library::op::Op;
 use npc_fwk::base::PropertyValue;
-use npc_fwk::err_out;
+use npc_fwk::{err_out, on_err_out};
 
 pub struct ClientImpl {
     terminate: sync::Arc<atomic::AtomicBool>,
-    tasks: sync::Arc<(sync::Mutex<VecDeque<Op>>, sync::Condvar)>,
+    sender: mpsc::Sender<Op>,
 }
 
 impl Drop for ClientImpl {
@@ -47,154 +46,135 @@ impl Drop for ClientImpl {
 
 impl ClientImpl {
     pub fn new(dir: PathBuf, sender: npc_fwk::toolkit::Sender<LibNotification>) -> ClientImpl {
-        let tasks = sync::Arc::new((sync::Mutex::new(VecDeque::new()), sync::Condvar::new()));
+        let (task_sender, task_receiver) = mpsc::channel::<Op>();
+
         let mut terminate = sync::Arc::new(atomic::AtomicBool::new(false));
-        let tasks2 = tasks.clone();
         let terminate2 = terminate.clone();
 
         /* let thread = */
         thread::spawn(move || {
             let library = Library::new(&dir, None, sender);
-            Self::main(&mut terminate, &tasks, &library);
+            Self::main(&mut terminate, task_receiver, &library);
         });
 
         ClientImpl {
             terminate: terminate2,
-            tasks: tasks2,
+            sender: task_sender,
         }
     }
 
     fn stop(&mut self) {
         self.terminate.store(true, atomic::Ordering::Relaxed);
-        self.tasks.1.notify_one();
     }
 
     fn main(
         terminate: &mut sync::Arc<atomic::AtomicBool>,
-        tasks: &sync::Arc<(sync::Mutex<VecDeque<Op>>, sync::Condvar)>,
+        tasks: mpsc::Receiver<Op>,
         library: &Library,
     ) {
         while !terminate.load(atomic::Ordering::Relaxed) {
-            let elem: Option<Op>;
-            {
-                let mut queue = tasks.0.lock().unwrap();
-                if !queue.is_empty() {
-                    elem = queue.pop_front();
-                } else {
-                    elem = None;
-                }
-            }
+            let elem: Option<Op> = tasks.recv().ok();
 
             if let Some(op) = elem {
                 op.execute(library);
             }
-
-            let queue = tasks.0.lock().unwrap();
-            if queue.is_empty() {
-                if let Err(err) = tasks.1.wait(queue) {
-                    err_out!("queue lock poisonned: {}", err);
-                    break;
-                }
-            }
         }
     }
 
-    pub fn schedule_op<F>(&mut self, f: F)
+    pub fn schedule_op<F>(&self, f: F)
     where
         F: Fn(&Library) -> bool + Send + Sync + 'static,
     {
         let op = Op::new(f);
 
-        let mut queue = self.tasks.0.lock().unwrap();
-        queue.push_back(op);
-        self.tasks.1.notify_all();
+        on_err_out!(self.sender.send(op));
     }
 }
 
 impl ClientInterface for ClientImpl {
     /// get all the keywords
-    fn get_all_keywords(&mut self) {
+    fn get_all_keywords(&self) {
         self.schedule_op(commands::cmd_list_all_keywords);
     }
 
-    fn query_keyword_content(&mut self, keyword_id: LibraryId) {
+    fn query_keyword_content(&self, keyword_id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_query_keyword_content(lib, keyword_id));
     }
 
-    fn count_keyword(&mut self, id: LibraryId) {
+    fn count_keyword(&self, id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_count_keyword(lib, id));
     }
 
     /// get all the folder
-    fn get_all_folders(&mut self) {
+    fn get_all_folders(&self) {
         self.schedule_op(commands::cmd_list_all_folders);
     }
 
-    fn query_folder_content(&mut self, folder_id: LibraryId) {
+    fn query_folder_content(&self, folder_id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_query_folder_content(lib, folder_id));
     }
 
-    fn count_folder(&mut self, folder_id: LibraryId) {
+    fn count_folder(&self, folder_id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_count_folder(lib, folder_id));
     }
 
-    fn create_folder(&mut self, name: String, path: Option<String>) {
+    fn create_folder(&self, name: String, path: Option<String>) {
         self.schedule_op(move |lib| commands::cmd_create_folder(lib, &name, path.clone()) != 0);
     }
 
-    fn delete_folder(&mut self, id: LibraryId) {
+    fn delete_folder(&self, id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_delete_folder(lib, id));
     }
 
-    fn request_metadata(&mut self, file_id: LibraryId) {
+    fn request_metadata(&self, file_id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_request_metadata(lib, file_id));
     }
 
     /// set the metadata
-    fn set_metadata(&mut self, file_id: LibraryId, meta: Np, value: &PropertyValue) {
+    fn set_metadata(&self, file_id: LibraryId, meta: Np, value: &PropertyValue) {
         let value2 = value.clone();
         self.schedule_op(move |lib| commands::cmd_set_metadata(lib, file_id, meta, &value2));
     }
-    fn write_metadata(&mut self, file_id: LibraryId) {
+    fn write_metadata(&self, file_id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_write_metadata(lib, file_id));
     }
 
-    fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId, to: LibraryId) {
+    fn move_file_to_folder(&self, file_id: LibraryId, from: LibraryId, to: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_move_file_to_folder(lib, file_id, from, to));
     }
 
     /// get all the labels
-    fn get_all_labels(&mut self) {
+    fn get_all_labels(&self) {
         self.schedule_op(commands::cmd_list_all_labels);
     }
-    fn create_label(&mut self, name: String, colour: String) {
+    fn create_label(&self, name: String, colour: String) {
         self.schedule_op(move |lib| commands::cmd_create_label(lib, &name, &colour) != 0);
     }
-    fn delete_label(&mut self, label_id: LibraryId) {
+    fn delete_label(&self, label_id: LibraryId) {
         self.schedule_op(move |lib| commands::cmd_delete_label(lib, label_id));
     }
     /// update a label
-    fn update_label(&mut self, label_id: LibraryId, new_name: String, new_colour: String) {
+    fn update_label(&self, label_id: LibraryId, new_name: String, new_colour: String) {
         self.schedule_op(move |lib| {
             commands::cmd_update_label(lib, label_id, &new_name, &new_colour)
         });
     }
 
     /// tell to process the Xmp update Queue
-    fn process_xmp_update_queue(&mut self, write_xmp: bool) {
+    fn process_xmp_update_queue(&self, write_xmp: bool) {
         self.schedule_op(move |lib| commands::cmd_process_xmp_update_queue(lib, write_xmp));
     }
 
     /// Import files from a directory
     /// @param dir the directory
     /// @param manage true if imports have to be managed
-    fn import_files(&mut self, dir: String, files: Vec<PathBuf>, manage: Managed) {
+    fn import_files(&self, dir: String, files: Vec<PathBuf>, manage: Managed) {
         self.schedule_op(move |lib| commands::cmd_import_files(lib, &dir, &files, manage));
     }
 }
 
 impl ClientInterfaceSync for ClientImpl {
-    fn create_label_sync(&mut self, name: String, colour: String) -> LibraryId {
+    fn create_label_sync(&self, name: String, colour: String) -> LibraryId {
         // can't use futures::sync::oneshot
         let (tx, rx) = mpsc::sync_channel::<LibraryId>(1);
 
@@ -207,7 +187,7 @@ impl ClientInterfaceSync for ClientImpl {
         rx.recv().unwrap()
     }
 
-    fn create_keyword_sync(&mut self, keyword: String) -> LibraryId {
+    fn create_keyword_sync(&self, keyword: String) -> LibraryId {
         // can't use futures::sync::oneshot
         let (tx, rx) = mpsc::sync_channel::<LibraryId>(1);
 
@@ -219,7 +199,7 @@ impl ClientInterfaceSync for ClientImpl {
         rx.recv().unwrap()
     }
 
-    fn create_folder_sync(&mut self, name: String, path: Option<String>) -> LibraryId {
+    fn create_folder_sync(&self, name: String, path: Option<String>) -> LibraryId {
         // can't use futures::sync::oneshot
         let (tx, rx) = mpsc::sync_channel::<LibraryId>(1);
 
diff --git a/niepce-main/src/libraryclient/clientinterface.rs 
b/niepce-main/src/libraryclient/clientinterface.rs
index f7d159a..d976a92 100644
--- a/niepce-main/src/libraryclient/clientinterface.rs
+++ b/niepce-main/src/libraryclient/clientinterface.rs
@@ -27,49 +27,49 @@ use npc_fwk::base::PropertyValue;
 /// Client interface.
 pub trait ClientInterface {
     /// get all the keywords
-    fn get_all_keywords(&mut self);
-    fn query_keyword_content(&mut self, id: LibraryId);
-    fn count_keyword(&mut self, id: LibraryId);
+    fn get_all_keywords(&self);
+    fn query_keyword_content(&self, id: LibraryId);
+    fn count_keyword(&self, id: LibraryId);
 
     /// get all the folder
-    fn get_all_folders(&mut self);
-    fn query_folder_content(&mut self, id: LibraryId);
-    fn count_folder(&mut self, id: LibraryId);
-    fn create_folder(&mut self, name: String, path: Option<String>);
-    fn delete_folder(&mut self, id: LibraryId);
+    fn get_all_folders(&self);
+    fn query_folder_content(&self, id: LibraryId);
+    fn count_folder(&self, id: LibraryId);
+    fn create_folder(&self, name: String, path: Option<String>);
+    fn delete_folder(&self, id: LibraryId);
 
-    fn request_metadata(&mut self, id: LibraryId);
+    fn request_metadata(&self, id: LibraryId);
     /// set the metadata
-    fn set_metadata(&mut self, id: LibraryId, meta: Np, value: &PropertyValue);
-    fn write_metadata(&mut self, id: LibraryId);
+    fn set_metadata(&self, id: LibraryId, meta: Np, value: &PropertyValue);
+    fn write_metadata(&self, id: LibraryId);
 
-    fn move_file_to_folder(&mut self, file_id: LibraryId, from: LibraryId, to: LibraryId);
+    fn move_file_to_folder(&self, file_id: LibraryId, from: LibraryId, to: LibraryId);
     /// get all the labels
-    fn get_all_labels(&mut self);
-    fn create_label(&mut self, label: String, colour: String);
-    fn delete_label(&mut self, id: LibraryId);
+    fn get_all_labels(&self);
+    fn create_label(&self, label: String, colour: String);
+    fn delete_label(&self, id: LibraryId);
     /// update a label
-    fn update_label(&mut self, id: LibraryId, new_name: String, new_colour: String);
+    fn update_label(&self, id: LibraryId, new_name: String, new_colour: String);
 
     /// tell to process the Xmp update Queue
-    fn process_xmp_update_queue(&mut self, write_xmp: bool);
+    fn process_xmp_update_queue(&self, write_xmp: bool);
 
     /// Import files from a directory
     /// @param dir the directory
     /// @param files the files to import
     /// @param manage true if imports have to be managed
-    fn import_files(&mut self, dir: String, files: Vec<PathBuf>, manage: Managed);
+    fn import_files(&self, dir: String, files: Vec<PathBuf>, manage: Managed);
 }
 
 /// Sync client interface
 pub trait ClientInterfaceSync {
     /// Create a keyword. Return the id for the keyword.
     /// If the keyword already exists, return its `LibraryId`.
-    fn create_keyword_sync(&mut self, keyword: String) -> LibraryId;
+    fn create_keyword_sync(&self, keyword: String) -> LibraryId;
 
     /// Create a label. Return the id of the newly created label.
-    fn create_label_sync(&mut self, name: String, colour: String) -> LibraryId;
+    fn create_label_sync(&self, name: String, colour: String) -> LibraryId;
 
     /// Create a folder. Return the id of the newly created folder.
-    fn create_folder_sync(&mut self, name: String, path: Option<String>) -> LibraryId;
+    fn create_folder_sync(&self, name: String, path: Option<String>) -> LibraryId;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]