[niepce] npc-engine: Cargo format



commit 1244468516f15bf1ccf574f587eeadd3e9d01667
Author: Hubert Figuière <hub figuiere net>
Date:   Sun Oct 27 17:03:06 2019 -0400

    npc-engine: Cargo format

 crates/npc-engine/build.rs                    |   2 +-
 crates/npc-engine/src/db/filebundle.rs        |  20 +++-
 crates/npc-engine/src/db/fsfile.rs            |   7 +-
 crates/npc-engine/src/db/keyword.rs           |  22 ++--
 crates/npc-engine/src/db/label.rs             |  20 ++--
 crates/npc-engine/src/db/libfile.rs           | 110 ++++++++---------
 crates/npc-engine/src/db/libfolder.rs         |  17 +--
 crates/npc-engine/src/db/libmetadata.rs       |  86 ++++++++------
 crates/npc-engine/src/db/library.rs           | 100 +++++++++-------
 crates/npc-engine/src/db/mod.rs               |   5 +-
 crates/npc-engine/src/library/commands.rs     | 163 ++++++++++++++------------
 crates/npc-engine/src/library/mod.rs          |   2 -
 crates/npc-engine/src/library/notification.rs | 142 ++++++++++++----------
 crates/npc-engine/src/library/op.rs           |   6 +-
 14 files changed, 386 insertions(+), 316 deletions(-)
---
diff --git a/crates/npc-engine/build.rs b/crates/npc-engine/build.rs
index cdc6e7b..372934b 100644
--- a/crates/npc-engine/build.rs
+++ b/crates/npc-engine/build.rs
@@ -46,7 +46,7 @@ fn main() {
     let bindings = builder
         .rustfmt_bindings(true)
         .generate()
-    // Unwrap the Result and panic on failure.
+        // Unwrap the Result and panic on failure.
         .expect("Unable to generate bindings");
 
     // Write the bindings to the $OUT_DIR/bindings.rs file.
diff --git a/crates/npc-engine/src/db/filebundle.rs b/crates/npc-engine/src/db/filebundle.rs
index 7fa0cdb..ec6c9ea 100644
--- a/crates/npc-engine/src/db/filebundle.rs
+++ b/crates/npc-engine/src/db/filebundle.rs
@@ -21,8 +21,8 @@ use std::ffi::OsString;
 use std::path::{Path, PathBuf};
 
 use crate::db::libfile::FileType;
-use npc_fwk::MimeType;
 use npc_fwk::toolkit::mimetype::{IsRaw, MType};
+use npc_fwk::MimeType;
 
 /// Sidecar.
 #[derive(Debug, PartialEq)]
@@ -327,8 +327,12 @@ mod test {
         }
 
         if let Some(b) = iter.next() {
-            println!("main = {}, jpeg = {}, xmp_sidecar = {}, sidecars =",
-                     b.main(), b.jpeg(), b.xmp_sidecar() /*, b.sidecars()*/);
+            println!(
+                "main = {}, jpeg = {}, xmp_sidecar = {}, sidecars =",
+                b.main(),
+                b.jpeg(),
+                b.xmp_sidecar() /*, b.sidecars()*/
+            );
             assert_eq!(b.bundle_type(), FileType::RAW_JPEG);
             assert_eq!(b.main(), "/foo/bar/scs_3445.raf");
             assert_eq!(b.jpeg(), "/foo/bar/scs_3445.jpg");
@@ -339,8 +343,12 @@ mod test {
         }
 
         if let Some(b) = iter.next() {
-            println!("main = {}, jpeg = {}, xmp_sidecar = {}, sidecars =",
-                     b.main(), b.jpeg(), b.xmp_sidecar() /*, b.sidecars()*/);
+            println!(
+                "main = {}, jpeg = {}, xmp_sidecar = {}, sidecars =",
+                b.main(),
+                b.jpeg(),
+                b.xmp_sidecar() /*, b.sidecars()*/
+            );
             assert_eq!(b.bundle_type(), FileType::RAW_JPEG);
             assert_eq!(b.main(), "/foo/bar/scs_3446.raf");
             assert_eq!(b.jpeg(), "/foo/bar/scs_3446.jpg");
@@ -349,5 +357,5 @@ mod test {
         } else {
             assert!(false);
         }
-}
+    }
 }
diff --git a/crates/npc-engine/src/db/fsfile.rs b/crates/npc-engine/src/db/fsfile.rs
index 95de96d..e213205 100644
--- a/crates/npc-engine/src/db/fsfile.rs
+++ b/crates/npc-engine/src/db/fsfile.rs
@@ -17,7 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-use std::path::{ Path, PathBuf };
+use std::path::{Path, PathBuf};
 
 use super::LibraryId;
 
@@ -28,11 +28,8 @@ pub struct FsFile {
 }
 
 impl FsFile {
-
     pub fn new(id: LibraryId, path: PathBuf) -> FsFile {
-        FsFile {
-            id, path,
-        }
+        FsFile { id, path }
     }
 
     pub fn id(&self) -> LibraryId {
diff --git a/crates/npc-engine/src/db/keyword.rs b/crates/npc-engine/src/db/keyword.rs
index 17fce1f..cfffce8 100644
--- a/crates/npc-engine/src/db/keyword.rs
+++ b/crates/npc-engine/src/db/keyword.rs
@@ -17,12 +17,12 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-use super::LibraryId;
 use super::FromDb;
+use super::LibraryId;
 use libc::c_char;
+use rusqlite;
 use std::ffi::CStr;
 use std::ffi::CString;
-use rusqlite;
 
 #[derive(Clone)]
 pub struct Keyword {
@@ -33,7 +33,8 @@ pub struct Keyword {
 impl Keyword {
     pub fn new(id: LibraryId, keyword: &str) -> Keyword {
         Keyword {
-            id, keyword: String::from(keyword),
+            id,
+            keyword: String::from(keyword),
         }
     }
 
@@ -60,29 +61,32 @@ impl FromDb for Keyword {
     }
 
     fn read_from(row: &rusqlite::Row) -> Self {
-        let kw : String = row.get(1);
+        let kw: String = row.get(1);
         Keyword::new(row.get(0), &kw)
     }
 }
 
 #[no_mangle]
-pub unsafe extern fn engine_db_keyword_new(id: i64, keyword: *const c_char) -> *mut Keyword {
-    let kw = Box::new(Keyword::new(id, &*CStr::from_ptr(keyword).to_string_lossy()));
+pub unsafe extern "C" fn engine_db_keyword_new(id: i64, keyword: *const c_char) -> *mut Keyword {
+    let kw = Box::new(Keyword::new(
+        id,
+        &*CStr::from_ptr(keyword).to_string_lossy(),
+    ));
     Box::into_raw(kw)
 }
 
 #[no_mangle]
-pub extern fn engine_db_keyword_id(obj: &Keyword) -> i64 {
+pub extern "C" fn engine_db_keyword_id(obj: &Keyword) -> i64 {
     obj.id() as i64
 }
 
 #[no_mangle]
-pub extern fn engine_db_keyword_keyword(obj: &Keyword) -> *mut c_char {
+pub extern "C" fn engine_db_keyword_keyword(obj: &Keyword) -> *mut c_char {
     let cstr = CString::new(obj.keyword().clone()).unwrap();
     cstr.into_raw()
 }
 
 #[no_mangle]
-pub unsafe extern fn engine_db_keyword_delete(kw: *mut Keyword) {
+pub unsafe extern "C" fn engine_db_keyword_delete(kw: *mut Keyword) {
     Box::from_raw(kw);
 }
diff --git a/crates/npc-engine/src/db/label.rs b/crates/npc-engine/src/db/label.rs
index 4e4982a..bf914ae 100644
--- a/crates/npc-engine/src/db/label.rs
+++ b/crates/npc-engine/src/db/label.rs
@@ -18,12 +18,12 @@
  */
 
 use libc::c_char;
+use rusqlite;
 use std::ffi::CString;
 use std::str::FromStr;
-use rusqlite;
 
-use super::LibraryId;
 use super::FromDb;
+use super::LibraryId;
 use npc_fwk::base::rgbcolour::RgbColour;
 
 #[derive(Clone)]
@@ -35,7 +35,6 @@ pub struct Label {
 }
 
 impl Label {
-
     pub fn new(id: LibraryId, label: &str, colourstring: &str) -> Label {
         let colour = RgbColour::from_str(colourstring).unwrap_or_default();
         Label {
@@ -81,30 +80,29 @@ impl FromDb for Label {
     }
 
     fn read_from(row: &rusqlite::Row) -> Self {
-        let label : String = row.get(1);
-        let colour : String = row.get(2);
+        let label: String = row.get(1);
+        let colour: String = row.get(2);
         Label::new(row.get(0), &label, &colour)
     }
 }
 
-
 #[no_mangle]
-pub unsafe extern fn engine_db_label_delete(l: *mut Label) {
+pub unsafe extern "C" fn engine_db_label_delete(l: *mut Label) {
     Box::from_raw(l);
 }
 
 #[no_mangle]
-pub extern fn engine_db_label_clone(l: &Label) -> *mut Label {
+pub extern "C" fn engine_db_label_clone(l: &Label) -> *mut Label {
     Box::into_raw(Box::new(l.clone()))
 }
 
 #[no_mangle]
-pub extern fn engine_db_label_id(l: &Label) -> LibraryId {
+pub extern "C" fn engine_db_label_id(l: &Label) -> LibraryId {
     l.id()
 }
 
 #[no_mangle]
-pub extern fn engine_db_label_label(obj: &mut Label) -> *const c_char {
+pub extern "C" fn engine_db_label_label(obj: &mut Label) -> *const c_char {
     let cstr;
     {
         let s = obj.label();
@@ -115,6 +113,6 @@ pub extern fn engine_db_label_label(obj: &mut Label) -> *const c_char {
 }
 
 #[no_mangle]
-pub extern fn engine_db_label_colour(l: &Label) -> *const RgbColour {
+pub extern "C" fn engine_db_label_colour(l: &Label) -> *const RgbColour {
     l.colour()
 }
diff --git a/crates/npc-engine/src/db/libfile.rs b/crates/npc-engine/src/db/libfile.rs
index b081a9c..0fd4039 100644
--- a/crates/npc-engine/src/db/libfile.rs
+++ b/crates/npc-engine/src/db/libfile.rs
@@ -18,18 +18,18 @@
  */
 
 use libc::c_char;
+use rusqlite;
 use std::ffi::CStr;
 use std::ffi::CString;
 use std::mem::transmute;
 use std::path::{Path, PathBuf};
-use rusqlite;
 
+use super::fsfile::FsFile;
 use super::FromDb;
 use super::LibraryId;
-use super::fsfile::FsFile;
 use crate::root::eng::NiepceProperties as Np;
-use npc_fwk::base::PropertyIndex;
 use npc_fwk;
+use npc_fwk::base::PropertyIndex;
 
 #[repr(i32)]
 #[allow(non_camel_case_types)]
@@ -91,16 +91,24 @@ pub struct LibFile {
 }
 
 impl LibFile {
-
-    pub fn new(id: LibraryId, folder_id: LibraryId, fs_file_id: LibraryId,
-               path: PathBuf, name: &str) -> LibFile {
+    pub fn new(
+        id: LibraryId,
+        folder_id: LibraryId,
+        fs_file_id: LibraryId,
+        path: PathBuf,
+        name: &str,
+    ) -> LibFile {
         let main_file = FsFile::new(fs_file_id, path);
         LibFile {
-            id, folder_id,
+            id,
+            folder_id,
             name: String::from(name),
             cstr: CString::new("").unwrap(),
-            main_file, orientation: 0,
-            rating: 0, label: 0, flag: 0,
+            main_file,
+            orientation: 0,
+            rating: 0,
+            label: 0,
+            flag: 0,
             file_type: FileType::UNKNOWN,
         }
     }
@@ -158,31 +166,21 @@ impl LibFile {
 
     pub fn property(&self, idx: Np) -> i32 {
         match idx {
-            Np::NpTiffOrientationProp =>
-                self.orientation(),
-            Np::NpXmpRatingProp =>
-                self.rating(),
-            Np::NpXmpLabelProp =>
-                self.label(),
-            Np::NpNiepceFlagProp =>
-                self.flag(),
-            _ =>
-                -1,
+            Np::NpTiffOrientationProp => self.orientation(),
+            Np::NpXmpRatingProp => self.rating(),
+            Np::NpXmpLabelProp => self.label(),
+            Np::NpNiepceFlagProp => self.flag(),
+            _ => -1,
         }
     }
 
     pub fn set_property(&mut self, idx: Np, value: i32) {
         match idx {
-            Np::NpTiffOrientationProp =>
-                self.set_orientation(value),
-            Np::NpXmpRatingProp =>
-                self.set_rating(value),
-            Np::NpXmpLabelProp =>
-                self.set_label(value),
-            Np::NpNiepceFlagProp =>
-                self.set_flag(value),
-            _ =>
-                err_out!("invalid property {:?} - noop", idx),
+            Np::NpTiffOrientationProp => self.set_orientation(value),
+            Np::NpXmpRatingProp => self.set_rating(value),
+            Np::NpXmpLabelProp => self.set_label(value),
+            Np::NpNiepceFlagProp => self.set_flag(value),
+            _ => err_out!("invalid property {:?} - noop", idx),
         };
     }
 
@@ -246,94 +244,100 @@ pub fn mimetype_to_filetype(mime: &npc_fwk::MimeType) -> FileType {
 }
 
 #[no_mangle]
-pub unsafe extern fn engine_db_libfile_new(id: LibraryId, folder_id: LibraryId,
-                                    fs_file_id: LibraryId, path: *const c_char,
-                                    name: *const c_char) -> *mut LibFile {
-    let lf = Box::new(
-        LibFile::new(id, folder_id, fs_file_id,
-                     PathBuf::from(&*CStr::from_ptr(path).to_string_lossy()),
-                     &*CStr::from_ptr(name).to_string_lossy())
-            );
+pub unsafe extern "C" fn engine_db_libfile_new(
+    id: LibraryId,
+    folder_id: LibraryId,
+    fs_file_id: LibraryId,
+    path: *const c_char,
+    name: *const c_char,
+) -> *mut LibFile {
+    let lf = Box::new(LibFile::new(
+        id,
+        folder_id,
+        fs_file_id,
+        PathBuf::from(&*CStr::from_ptr(path).to_string_lossy()),
+        &*CStr::from_ptr(name).to_string_lossy(),
+    ));
     Box::into_raw(lf)
 }
 
 #[no_mangle]
-pub unsafe extern fn engine_db_libfile_delete(lf: *mut LibFile) {
+pub unsafe extern "C" fn engine_db_libfile_delete(lf: *mut LibFile) {
     Box::from_raw(lf);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_path(obj: &mut LibFile) -> *const c_char {
+pub extern "C" fn engine_db_libfile_path(obj: &mut LibFile) -> *const c_char {
     obj.cstr = CString::new(obj.path().to_str().unwrap_or("")).unwrap();
     obj.cstr.as_ptr()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_id(obj: &LibFile) -> LibraryId {
+pub extern "C" fn engine_db_libfile_id(obj: &LibFile) -> LibraryId {
     obj.id()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_folderid(obj: &LibFile) -> LibraryId {
+pub extern "C" fn engine_db_libfile_folderid(obj: &LibFile) -> LibraryId {
     obj.folder_id()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_orientation(obj: &LibFile) -> i32 {
+pub extern "C" fn engine_db_libfile_orientation(obj: &LibFile) -> i32 {
     obj.orientation()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_rating(obj: &LibFile) -> i32 {
+pub extern "C" fn engine_db_libfile_rating(obj: &LibFile) -> i32 {
     obj.rating()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_label(obj: &LibFile) -> i32 {
+pub extern "C" fn engine_db_libfile_label(obj: &LibFile) -> i32 {
     obj.label()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_flag(obj: &LibFile) -> i32 {
+pub extern "C" fn engine_db_libfile_flag(obj: &LibFile) -> i32 {
     obj.flag()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_property(obj: &LibFile, idx: PropertyIndex) -> i32 {
+pub extern "C" fn engine_db_libfile_property(obj: &LibFile, idx: PropertyIndex) -> i32 {
     obj.property(unsafe { transmute(idx) })
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_file_type(obj: &LibFile) -> FileType {
+pub extern "C" fn engine_db_libfile_file_type(obj: &LibFile) -> FileType {
     obj.file_type()
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_set_orientation(obj: &mut LibFile, o: i32) {
+pub extern "C" fn engine_db_libfile_set_orientation(obj: &mut LibFile, o: i32) {
     obj.set_orientation(o);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_set_rating(obj: &mut LibFile, r: i32) {
+pub extern "C" fn engine_db_libfile_set_rating(obj: &mut LibFile, r: i32) {
     obj.set_rating(r);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_set_label(obj: &mut LibFile, l: i32) {
+pub extern "C" fn engine_db_libfile_set_label(obj: &mut LibFile, l: i32) {
     obj.set_label(l);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_set_flag(obj: &mut LibFile, f: i32) {
+pub extern "C" fn engine_db_libfile_set_flag(obj: &mut LibFile, f: i32) {
     obj.set_flag(f);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_set_property(obj: &mut LibFile, idx: PropertyIndex, v: i32) {
+pub extern "C" fn engine_db_libfile_set_property(obj: &mut LibFile, idx: PropertyIndex, v: i32) {
     obj.set_property(unsafe { transmute(idx) }, v);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfile_set_file_type(obj: &mut LibFile, t: FileType) {
+pub extern "C" fn engine_db_libfile_set_file_type(obj: &mut LibFile, t: FileType) {
     obj.set_file_type(t);
 }
diff --git a/crates/npc-engine/src/db/libfolder.rs b/crates/npc-engine/src/db/libfolder.rs
index a0196e4..f5107fe 100644
--- a/crates/npc-engine/src/db/libfolder.rs
+++ b/crates/npc-engine/src/db/libfolder.rs
@@ -18,8 +18,8 @@
  */
 
 use libc::c_char;
-use std::ffi::CString;
 use rusqlite;
+use std::ffi::CString;
 
 use super::FromDb;
 use super::LibraryId;
@@ -28,7 +28,7 @@ use super::LibraryId;
 #[derive(Clone)]
 pub enum FolderVirtualType {
     NONE = 0,
-    TRASH = 1
+    TRASH = 1,
 }
 
 impl From<i32> for FolderVirtualType {
@@ -58,10 +58,12 @@ pub struct LibFolder {
 impl LibFolder {
     pub fn new(id: LibraryId, name: &str, path: Option<String>) -> LibFolder {
         LibFolder {
-            id, name: String::from(name),
+            id,
+            name: String::from(name),
             path,
             locked: false,
-            expanded: false, virt: FolderVirtualType::NONE,
+            expanded: false,
+            virt: FolderVirtualType::NONE,
             parent: 0,
             cstr: CString::new("").unwrap(),
         }
@@ -109,7 +111,6 @@ impl LibFolder {
 }
 
 impl FromDb for LibFolder {
-
     fn read_db_columns() -> &'static str {
         "id,name,virtual,locked,expanded,path,parent_id"
     }
@@ -163,16 +164,16 @@ pub extern "C" fn engine_db_libfolder_expanded(obj: &LibFolder) -> bool {
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfolder_set_locked(obj: &mut LibFolder, locked: bool) {
+pub extern "C" fn engine_db_libfolder_set_locked(obj: &mut LibFolder, locked: bool) {
     obj.set_locked(locked);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfolder_set_expanded(obj: &mut LibFolder, expanded: bool) {
+pub extern "C" fn engine_db_libfolder_set_expanded(obj: &mut LibFolder, expanded: bool) {
     obj.set_expanded(expanded);
 }
 
 #[no_mangle]
-pub extern fn engine_db_libfolder_set_virtual_type(obj: &mut LibFolder, t: FolderVirtualType) {
+pub extern "C" fn engine_db_libfolder_set_virtual_type(obj: &mut LibFolder, t: FolderVirtualType) {
     obj.set_virtual_type(t);
 }
diff --git a/crates/npc-engine/src/db/libmetadata.rs b/crates/npc-engine/src/db/libmetadata.rs
index 391bb6e..567546a 100644
--- a/crates/npc-engine/src/db/libmetadata.rs
+++ b/crates/npc-engine/src/db/libmetadata.rs
@@ -17,17 +17,17 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-use std::ffi::CStr;
-use std::mem::transmute;
-use rusqlite;
 use chrono::Utc;
 use exempi;
+use rusqlite;
+use std::ffi::CStr;
+use std::mem::transmute;
 
-use npc_fwk::{xmp_date_from, PropertyBag, PropertySet, PropertyValue, XmpMeta};
-use npc_fwk::utils::exempi::{NS_DC, NS_XAP};
 use super::{FromDb, LibraryId};
-use crate::root::eng::NiepceProperties as Np;
 use crate::db::libfile::FileType;
+use crate::root::eng::NiepceProperties as Np;
+use npc_fwk::utils::exempi::{NS_DC, NS_XAP};
+use npc_fwk::{xmp_date_from, PropertyBag, PropertySet, PropertyValue, XmpMeta};
 
 #[derive(Clone)]
 pub struct LibMetadata {
@@ -61,9 +61,10 @@ impl LibMetadata {
         LibMetadata {
             xmp: XmpMeta::new(),
             id,
-            sidecars: vec![], file_type: FileType::UNKNOWN,
+            sidecars: vec![],
+            file_type: FileType::UNKNOWN,
             name: String::new(),
-            folder: String::new()
+            folder: String::new(),
         }
     }
 
@@ -74,7 +75,7 @@ impl LibMetadata {
             sidecars: vec![],
             file_type: FileType::UNKNOWN,
             name: String::new(),
-            folder: String::new()
+            folder: String::new(),
         }
     }
 
@@ -109,28 +110,37 @@ impl LibMetadata {
     pub fn set_metadata(&mut self, meta: Np, value: &PropertyValue) -> bool {
         if let Some(ix) = property_index_to_xmp(meta) {
             match *value {
-                PropertyValue::Empty => return self.xmp.xmp.delete_property(&ix.ns, &ix.property).is_ok(),
+                PropertyValue::Empty => {
+                    return self.xmp.xmp.delete_property(&ix.ns, &ix.property).is_ok()
+                }
                 PropertyValue::Int(i) => {
-                    return self.xmp
+                    return self
+                        .xmp
                         .xmp
-                        .set_property_i32(&ix.ns, &ix.property, i, exempi::PROP_NONE).is_ok()
+                        .set_property_i32(&ix.ns, &ix.property, i, exempi::PROP_NONE)
+                        .is_ok()
                 }
                 PropertyValue::String(ref s) => {
                     if s.is_empty() {
                         return self.xmp.xmp.delete_property(&ix.ns, &ix.property).is_ok();
-                    } else if self.xmp
+                    } else if self
                         .xmp
-                        .set_property(&ix.ns, &ix.property, s, exempi::PROP_NONE).is_err()
+                        .xmp
+                        .set_property(&ix.ns, &ix.property, s, exempi::PROP_NONE)
+                        .is_err()
                     {
                         if exempi::get_error() == exempi::Error::BadXPath {
-                            return self.xmp.xmp.set_localized_text(
-                                &ix.ns,
-                                &ix.property,
-                                "",
-                                "x-default",
-                                s,
-                                exempi::PROP_NONE,
-                            ).is_ok();
+                            return self
+                                .xmp
+                                .xmp
+                                .set_localized_text(
+                                    &ix.ns,
+                                    &ix.property,
+                                    "",
+                                    "x-default",
+                                    s,
+                                    exempi::PROP_NONE,
+                                ).is_ok();
                         }
                     } else {
                         return true;
@@ -142,13 +152,17 @@ impl LibMetadata {
                         return false;
                     }
                     for s in sa {
-                        if self.xmp.xmp.append_array_item(
-                            &ix.ns,
-                            &ix.property,
-                            exempi::PROP_VALUE_IS_ARRAY,
-                            s,
-                            exempi::PROP_NONE,
-                        ).is_err() {
+                        if self
+                            .xmp
+                            .xmp
+                            .append_array_item(
+                                &ix.ns,
+                                &ix.property,
+                                exempi::PROP_VALUE_IS_ARRAY,
+                                s,
+                                exempi::PROP_NONE,
+                            ).is_err()
+                        {
                             err_out!("Error appending array item {} in property {}", &s, &ix.ns);
                             return false;
                         }
@@ -157,12 +171,11 @@ impl LibMetadata {
                 }
                 PropertyValue::Date(ref d) => {
                     let xmp_date = xmp_date_from(d);
-                    return self.xmp.xmp.set_property_date(
-                        &ix.ns,
-                        &ix.property,
-                        &xmp_date,
-                        exempi::PROP_NONE,
-                    ).is_ok();
+                    return self
+                        .xmp
+                        .xmp
+                        .set_property_date(&ix.ns, &ix.property, &xmp_date, exempi::PROP_NONE)
+                        .is_ok();
                 }
             }
             err_out!(
@@ -248,7 +261,8 @@ impl LibMetadata {
         let xmpdate = xmp_date_from(&Utc::now());
         self.xmp
             .xmp
-            .set_property_date(NS_XAP, "MetadataDate", &xmpdate, exempi::PROP_NONE).is_ok()
+            .set_property_date(NS_XAP, "MetadataDate", &xmpdate, exempi::PROP_NONE)
+            .is_ok()
     }
 }
 
diff --git a/crates/npc-engine/src/db/library.rs b/crates/npc-engine/src/db/library.rs
index 4184e5f..61e9638 100644
--- a/crates/npc-engine/src/db/library.rs
+++ b/crates/npc-engine/src/db/library.rs
@@ -85,7 +85,7 @@ impl Library {
             dbpath: PathBuf::default(),
             dbconn: None,
             inited: false,
-            sender
+            sender,
         };
 
         if let Ok(conn) = rusqlite::Connection::open_in_memory() {
@@ -96,8 +96,11 @@ impl Library {
         lib
     }
 
-    pub fn new(dir: &Path, name: Option<&str>,
-               sender: npc_fwk::toolkit::Sender<LibNotification>) -> Library {
+    pub fn new(
+        dir: &Path,
+        name: Option<&str>,
+        sender: npc_fwk::toolkit::Sender<LibNotification>,
+    ) -> Library {
         let mut dbpath = PathBuf::from(dir);
         if let Some(filename) = name {
             dbpath.push(filename);
@@ -250,7 +253,7 @@ impl Library {
                  CREATE TRIGGER pre_file_delete_trigger BEFORE DELETE ON files \
                  BEGIN \
                  DELETE FROM fsfiles WHERE id = old.main_file \
-                                    OR id = old.xmp_file OR id = old.jpeg_file; \
+                 OR id = old.xmp_file OR id = old.jpeg_file; \
                  END; \
                  CREATE TRIGGER file_delete_trigger AFTER DELETE ON files \
                  BEGIN \
@@ -270,10 +273,12 @@ impl Library {
                  keyword_id INTEGER, UNIQUE(file_id, keyword_id))",
                 &[],
             ).unwrap();
-            conn.execute("CREATE TRIGGER keyword_delete_trigger AFTER DELETE ON keywords \
+            conn.execute(
+                "CREATE TRIGGER keyword_delete_trigger AFTER DELETE ON keywords \
                  BEGIN \
                  DELETE FROM keywording WHERE keyword_id = old.id; \
-                 END;", &[],
+                 END;",
+                &[],
             ).unwrap();
             conn.execute(
                 "CREATE TABLE labels (id INTEGER PRIMARY KEY,\
@@ -310,7 +315,10 @@ impl Library {
     /// Send a `LibNotification`.
     /// @returns the result (nothing or an error
     ///
-    pub fn notify(&self, notif: LibNotification) -> std::result::Result<(), 
mpsc::SendError<LibNotification>> {
+    pub fn notify(
+        &self,
+        notif: LibNotification,
+    ) -> std::result::Result<(), mpsc::SendError<LibNotification>> {
         self.sender.send(notif)
     }
 
@@ -618,7 +626,13 @@ impl Library {
         Ok(file_id)
     }
 
-    pub fn add_file(&self, folder_id: LibraryId, file: &str, bundle: Option<&FileBundle>, manage: Managed) 
-> Result<LibraryId> {
+    pub fn add_file(
+        &self,
+        folder_id: LibraryId,
+        file: &str,
+        bundle: Option<&FileBundle>,
+        manage: Managed,
+    ) -> Result<LibraryId> {
         dbg_assert!(manage == Managed::NO, "manage not supported");
         dbg_assert!(folder_id != -1, "invalid folder ID");
         let mime = npc_fwk::MimeType::new(file);
@@ -738,8 +752,11 @@ impl Library {
                 return Err(Error::InvalidResult);
             }
             let keyword_id = conn.last_insert_rowid();
-            if self.notify(LibNotification::AddedKeyword(Keyword::new(
-                keyword_id, keyword))).is_err() {
+            if self
+                .notify(LibNotification::AddedKeyword(Keyword::new(
+                    keyword_id, keyword,
+                ))).is_err()
+            {
                 err_out!("Failed to send AddedKeyword notification");
             }
             return Ok(keyword_id);
@@ -843,52 +860,46 @@ impl Library {
 
     pub fn set_metadata(&self, file_id: LibraryId, meta: Np, value: &PropertyValue) -> Result<()> {
         match meta {
-            Np::NpXmpRatingProp |
-            Np::NpXmpLabelProp |
-            Np::NpTiffOrientationProp |
-            Np::NpNiepceFlagProp => {
+            Np::NpXmpRatingProp
+            | Np::NpXmpLabelProp
+            | Np::NpTiffOrientationProp
+            | Np::NpNiepceFlagProp => {
                 match *value {
                     PropertyValue::Int(i) => {
                         // internal
                         // make the column mapping more generic.
                         let column = match meta {
-                            Np::NpXmpRatingProp =>
-                                "rating",
-                            Np::NpXmpLabelProp =>
-                                "orientation",
-                            Np::NpTiffOrientationProp =>
-                                "label",
-                            Np::NpNiepceFlagProp =>
-                                "flag",
-                            _ =>
-                                unreachable!()
+                            Np::NpXmpRatingProp => "rating",
+                            Np::NpXmpLabelProp => "orientation",
+                            Np::NpTiffOrientationProp => "label",
+                            Np::NpNiepceFlagProp => "flag",
+                            _ => unreachable!(),
                         };
                         if !column.is_empty() {
                             self.set_internal_metadata(file_id, column, i)?;
                         }
-                    },
-                    _ =>
-                        err_out!("improper value type for {:?}", meta),
+                    }
+                    _ => err_out!("improper value type for {:?}", meta),
                 }
-            },
+            }
             Np::NpIptcKeywordsProp => {
                 self.unassign_all_keywords_for_file(file_id)?;
 
                 match *value {
-                    PropertyValue::StringArray(ref keywords) =>
-                        for kw in keywords {
-                            let id = self.make_keyword(&kw)?;
-                            if id != -1 {
-                                self.assign_keyword(id, file_id)?;
-                            }
-                        },
-                    _ =>
-                        err_out!("improper value_type for {:?} : {:?}", meta, value),
+                    PropertyValue::StringArray(ref keywords) => for kw in keywords {
+                        let id = self.make_keyword(&kw)?;
+                        if id != -1 {
+                            self.assign_keyword(id, file_id)?;
+                        }
+                    },
+                    _ => err_out!("improper value_type for {:?} : {:?}", meta, value),
                 }
-            },
+            }
             _ =>
-                // XXX TODO
-                err_out!("unhandled meta {:?}", meta),
+            // XXX TODO
+            {
+                err_out!("unhandled meta {:?}", meta)
+            }
         }
         let mut metablock = self.get_metadata(file_id)?;
         metablock.set_metadata(meta, value);
@@ -1000,7 +1011,10 @@ impl Library {
         // 3. make sure the update happened correctly, possibly ensure we don't
         // clobber the xmp.
         if let Some(ref conn) = self.dbconn {
-            if conn.execute("DELETE FROM xmp_update_queue WHERE id=?1;", &[&id]).is_ok() {
+            if conn
+                .execute("DELETE FROM xmp_update_queue WHERE id=?1;", &[&id])
+                .is_ok()
+            {
                 // we don't want to write the XMP so we don't need to list them.
                 if !write_xmp {
                     return Ok(());
@@ -1080,7 +1094,6 @@ mod test {
 
     #[test]
     fn library_works() {
-
         let lib = Library::new_in_memory();
 
         assert!(lib.is_ok());
@@ -1189,7 +1202,6 @@ mod test {
         assert!(bundle_id.is_ok());
         assert!(bundle_id.ok().unwrap() > 0);
 
-
         let mut bundle = FileBundle::new();
         assert!(bundle.add("img_0124.jpg"));
         assert!(bundle.add("img_0124.raf"));
@@ -1197,5 +1209,5 @@ mod test {
         let bundle_id = lib.add_bundle(folder_added.id(), &bundle, Managed::NO);
         assert!(bundle_id.is_ok());
         assert!(bundle_id.ok().unwrap() > 0);
-}
+    }
 }
diff --git a/crates/npc-engine/src/db/mod.rs b/crates/npc-engine/src/db/mod.rs
index f5b6aa2..e9f2f27 100644
--- a/crates/npc-engine/src/db/mod.rs
+++ b/crates/npc-engine/src/db/mod.rs
@@ -29,13 +29,12 @@ pub mod library;
 pub type LibraryId = i64;
 
 // flatten namespace a bit.
+pub use self::keyword::Keyword;
 pub use self::label::Label;
-pub use self::libmetadata::LibMetadata;
 pub use self::libfolder::LibFolder;
-pub use self::keyword::Keyword;
+pub use self::libmetadata::LibMetadata;
 pub use self::library::Library;
 
-
 use rusqlite;
 
 pub trait FromDb {
diff --git a/crates/npc-engine/src/library/commands.rs b/crates/npc-engine/src/library/commands.rs
index ee22ec5..24d4db2 100644
--- a/crates/npc-engine/src/library/commands.rs
+++ b/crates/npc-engine/src/library/commands.rs
@@ -19,25 +19,17 @@
 
 use std::os::raw::c_void;
 
-use npc_fwk::PropertyValue;
-use crate::db::LibraryId;
-use crate::db::library;
-use crate::db::library::{
-    Library,
-    Managed
-};
+use super::notification::LibNotification;
+use super::notification::{Content, Count, FileMove, MetadataChange};
 use crate::db::filebundle::FileBundle;
 use crate::db::keyword::Keyword;
 use crate::db::label::Label;
 use crate::db::libfolder::LibFolder;
+use crate::db::library;
+use crate::db::library::{Library, Managed};
+use crate::db::LibraryId;
 use crate::root::eng::NiepceProperties as Np;
-use super::notification::LibNotification;
-use super::notification::{
-    Content,
-    Count,
-    FileMove,
-    MetadataChange,
-};
+use npc_fwk::PropertyValue;
 
 pub fn cmd_list_all_keywords(lib: &Library) -> bool {
     match lib.get_all_keywords() {
@@ -50,7 +42,7 @@ pub fn cmd_list_all_keywords(lib: &Library) -> bool {
                 }
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("get all keywords failed: {:?}", err);
             false
@@ -69,7 +61,7 @@ pub fn cmd_list_all_folders(lib: &Library) -> bool {
                 }
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("get_all_folders failed: {:?}", err);
             false
@@ -87,13 +79,13 @@ fn get_folder_for_import(lib: &Library, folder: &str) -> library::Result<LibFold
             // folder doesn't exist, we'll create it
             if let Some(name) = Library::leaf_name_for_pathname(folder) {
                 match lib.add_folder(&name, Some(String::from(folder))) {
-                    Ok(lf) =>  {
+                    Ok(lf) => {
                         let libfolder = lf.clone();
                         if lib.notify(LibNotification::AddedFolder(lf)).is_err() {
                             err_out!("Failed to notify AddedFolder");
                         }
                         Ok(libfolder)
-                    },
+                    }
                     Err(err) => {
                         err_out_line!("Add folder failed {:?}", err);
                         Err(err)
@@ -103,7 +95,7 @@ fn get_folder_for_import(lib: &Library, folder: &str) -> library::Result<LibFold
                 err_out_line!("Can't get folder name.");
                 Err(library::Error::InvalidResult)
             }
-        },
+        }
         Err(err) => {
             err_out_line!("get folder failed: {:?}", err);
             Err(err)
@@ -111,13 +103,15 @@ fn get_folder_for_import(lib: &Library, folder: &str) -> library::Result<LibFold
     }
 }
 
-pub fn cmd_import_files(lib: &Library, folder: &str, files: &[String],
-                        manage: Managed) -> bool {
-    dbg_assert!(manage == Managed::NO, "managing file is currently unsupported");
+pub fn cmd_import_files(lib: &Library, folder: &str, files: &[String], manage: Managed) -> bool {
+    dbg_assert!(
+        manage == Managed::NO,
+        "managing file is currently unsupported"
+    );
 
     let bundles = FileBundle::filter_bundles(files);
     match get_folder_for_import(lib, folder) {
-        Ok(libfolder) =>  {
+        Ok(libfolder) => {
             let folder_id = libfolder.id();
             for bundle in bundles {
                 // XXX properle handle this error. Should be a failure.
@@ -129,7 +123,7 @@ pub fn cmd_import_files(lib: &Library, folder: &str, files: &[String],
                 err_out!("Failed to notify AddedFiles");
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("Get folder for import {:?}", err);
             false
@@ -139,14 +133,14 @@ pub fn cmd_import_files(lib: &Library, folder: &str, files: &[String],
 
 pub fn cmd_create_folder(lib: &Library, name: &str, path: Option<String>) -> LibraryId {
     match lib.add_folder(name, path) {
-        Ok(lf) =>  {
+        Ok(lf) => {
             let id = lf.id();
             if lib.notify(LibNotification::AddedFolder(lf)).is_err() {
                 err_out!("Failed to notifu AddedFolder");
             }
             id
-        },
-        Err(err) =>  {
+        }
+        Err(err) => {
             err_out_line!("Folder creation failed {:?}", err);
             -1
         }
@@ -160,7 +154,7 @@ pub fn cmd_delete_folder(lib: &Library, id: LibraryId) -> bool {
                 err_out!("Failed to notify FolderDeleted");
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("Delete folder failed {:?}", err);
             false
@@ -177,10 +171,10 @@ pub fn cmd_request_metadata(lib: &Library, file_id: LibraryId) -> bool {
                 Err(err) => {
                     err_out!("Failed to notify Metadata {:?}", err);
                     false
-                },
-                Ok(_) => true
+                }
+                Ok(_) => true,
             }
-        },
+        }
         Err(err) => {
             err_out_line!("Get metadata failed {:?}", err);
             false
@@ -204,10 +198,10 @@ pub fn cmd_query_folder_content(lib: &Library, folder_id: LibraryId) -> bool {
                 Err(err) => {
                     err_out!("Failed to notify FolderContent {:?}", err);
                     false
-                },
-                Ok(_) => true
+                }
+                Ok(_) => true,
             }
-        },
+        }
         Err(err) => {
             err_out_line!("Get folder content failed {:?}", err);
             false
@@ -215,16 +209,20 @@ pub fn cmd_query_folder_content(lib: &Library, folder_id: LibraryId) -> bool {
     }
 }
 
-pub fn cmd_set_metadata(lib: &Library, id: LibraryId, meta: Np,
-                        value: &PropertyValue) -> bool {
+pub fn cmd_set_metadata(lib: &Library, id: LibraryId, meta: Np, value: &PropertyValue) -> bool {
     match lib.set_metadata(id, meta, value) {
         Ok(_) => {
-            if lib.notify(LibNotification::MetadataChanged(
-                MetadataChange::new(id, meta as u32, value.clone()))).is_err() {
+            if lib
+                .notify(LibNotification::MetadataChanged(MetadataChange::new(
+                    id,
+                    meta as u32,
+                    value.clone(),
+                ))).is_err()
+            {
                 err_out!("Failed to notify MetadataChange");
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("set_matadata failed: {:?}", err);
             false
@@ -237,16 +235,14 @@ pub fn cmd_count_folder(lib: &Library, id: LibraryId) -> bool {
         Ok(count) => {
             // This time it's a fatal error since the purpose of this comand
             // is to retrieve.
-            match lib.notify(LibNotification::FolderCounted(Count{id, count})) {
+            match lib.notify(LibNotification::FolderCounted(Count { id, count })) {
                 Err(err) => {
                     err_out!("Failed to notify FolderCounted {:?}", err);
                     false
-                },
-                Ok(_) => {
-                    true
                 }
+                Ok(_) => true,
             }
-        },
+        }
         Err(err) => {
             err_out_line!("count_folder failed: {:?}", err);
             false
@@ -257,11 +253,14 @@ pub fn cmd_count_folder(lib: &Library, id: LibraryId) -> bool {
 pub fn cmd_add_keyword(lib: &Library, keyword: &str) -> LibraryId {
     match lib.make_keyword(keyword) {
         Ok(id) => {
-            if lib.notify(LibNotification::AddedKeyword(Keyword::new(id, keyword))).is_err() {
+            if lib
+                .notify(LibNotification::AddedKeyword(Keyword::new(id, keyword)))
+                .is_err()
+            {
                 err_out!("Failed to notify AddedKeyword");
             }
             id
-        },
+        }
         Err(err) => {
             err_out_line!("make_keyword failed: {:?}", err);
             -1
@@ -282,10 +281,10 @@ pub fn cmd_query_keyword_content(lib: &Library, keyword_id: LibraryId) -> bool {
                 Err(err) => {
                     err_out!("Failed to notify KeywordContentQueried {:?}", err);
                     false
-                },
-                Ok(_) => true
+                }
+                Ok(_) => true,
             }
-        },
+        }
         Err(err) => {
             err_out_line!("get_keyword_content failed: {:?}", err);
             false
@@ -298,14 +297,14 @@ pub fn cmd_count_keyword(lib: &Library, id: LibraryId) -> bool {
         Ok(count) => {
             // This time it's a fatal error since the purpose of this comand
             // is to retrieve.
-            match lib.notify(LibNotification::KeywordCounted(Count{id, count})) {
+            match lib.notify(LibNotification::KeywordCounted(Count { id, count })) {
                 Err(err) => {
                     err_out!("Failed to notify KeywordCounted {:?}", err);
                     false
-                },
-                Ok(_) => true
+                }
+                Ok(_) => true,
             }
-        },
+        }
         Err(err) => {
             err_out_line!("count_keyword failed: {:?}", err);
             false
@@ -323,24 +322,41 @@ pub fn cmd_write_metadata(lib: &Library, file_id: LibraryId) -> bool {
     }
 }
 
-pub fn cmd_move_file_to_folder(lib: &Library, file_id: LibraryId, from: LibraryId,
-                               to: LibraryId) -> bool {
+pub fn cmd_move_file_to_folder(
+    lib: &Library,
+    file_id: LibraryId,
+    from: LibraryId,
+    to: LibraryId,
+) -> bool {
     match lib.move_file_to_folder(file_id, to) {
         Ok(_) => {
-            if lib.notify(LibNotification::FileMoved(FileMove{file: file_id, from, to}))
-                .is_err() {
-                    err_out!("Failed to notify FileMoved");
-                }
-            if lib.notify(LibNotification::FolderCountChanged(Count{id: from, count: -1}))
-                .is_err() {
-                    err_out!("Failed to notify FileMoved");
-                }
-            if lib.notify(LibNotification::FolderCountChanged(Count{id: to, count: 1}))
-                .is_err() {
-                    err_out!("Failed to notify FileMoved");
-                }
+            if lib
+                .notify(LibNotification::FileMoved(FileMove {
+                    file: file_id,
+                    from,
+                    to,
+                })).is_err()
+            {
+                err_out!("Failed to notify FileMoved");
+            }
+            if lib
+                .notify(LibNotification::FolderCountChanged(Count {
+                    id: from,
+                    count: -1,
+                })).is_err()
+            {
+                err_out!("Failed to notify FileMoved");
+            }
+            if lib
+                .notify(LibNotification::FolderCountChanged(Count {
+                    id: to,
+                    count: 1,
+                })).is_err()
+            {
+                err_out!("Failed to notify FileMoved");
+            }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("move file to folder failed: {:?}", err);
             false
@@ -359,7 +375,7 @@ pub fn cmd_list_all_labels(lib: &Library) -> bool {
                 }
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("get_all_labels failed: {:?}", err);
             false
@@ -375,7 +391,7 @@ pub fn cmd_create_label(lib: &Library, name: &str, colour: &str) -> LibraryId {
                 err_out!("Failed to notify AddedLabel");
             }
             id
-        },
+        }
         Err(err) => {
             err_out_line!("add_label failed: {:?}", err);
             -1
@@ -390,7 +406,7 @@ pub fn cmd_delete_label(lib: &Library, label_id: LibraryId) -> bool {
                 err_out!("Failed to notify LabelDeleted");
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("delete label failed: {:?}", err);
             false
@@ -398,8 +414,7 @@ pub fn cmd_delete_label(lib: &Library, label_id: LibraryId) -> bool {
     }
 }
 
-pub fn cmd_update_label(lib: &Library, label_id: LibraryId, name: &str,
-                        colour: &str) -> bool {
+pub fn cmd_update_label(lib: &Library, label_id: LibraryId, name: &str, colour: &str) -> bool {
     match lib.update_label(label_id, name, colour) {
         Ok(_) => {
             let label = Label::new(label_id, name, colour);
@@ -407,7 +422,7 @@ pub fn cmd_update_label(lib: &Library, label_id: LibraryId, name: &str,
                 err_out!("Failed to notify LabelChanged");
             }
             true
-        },
+        }
         Err(err) => {
             err_out_line!("update label failed: {:?}", err);
             false
diff --git a/crates/npc-engine/src/library/mod.rs b/crates/npc-engine/src/library/mod.rs
index 8d3e68d..a6fb41b 100644
--- a/crates/npc-engine/src/library/mod.rs
+++ b/crates/npc-engine/src/library/mod.rs
@@ -1,5 +1,3 @@
-
-
 pub mod commands;
 pub mod notification;
 pub mod op;
diff --git a/crates/npc-engine/src/library/notification.rs b/crates/npc-engine/src/library/notification.rs
index de9f8c3..5e0a0c1 100644
--- a/crates/npc-engine/src/library/notification.rs
+++ b/crates/npc-engine/src/library/notification.rs
@@ -17,17 +17,11 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+use crate::db::libfile::FileStatus;
+use crate::db::{Keyword, Label, LibFolder, LibMetadata, LibraryId};
 use npc_fwk::base::PropertyIndex;
-use npc_fwk::PropertyValue;
 use npc_fwk::toolkit::PortableChannel;
-use crate::db::{
-    LibraryId,
-    Label, LibFolder, LibMetadata, Keyword
-};
-use crate::db::libfile::{
-    FileStatus,
-};
-
+use npc_fwk::PropertyValue;
 
 #[cfg(not(test))]
 use crate::root::eng::QueriedContent;
@@ -39,9 +33,8 @@ pub type LcChannel = PortableChannel<LibNotification>;
 // Content need to be stubbed for the test as it is a FFI struct
 // and is missing the proper C++ code.
 #[cfg(test)]
-#[derive(Clone,Copy)]
-pub struct Content {
-}
+#[derive(Clone, Copy)]
+pub struct Content {}
 
 #[repr(i32)]
 #[allow(non_camel_case_types)]
@@ -100,7 +93,7 @@ pub struct MetadataChange {
 
 impl MetadataChange {
     pub fn new(id: LibraryId, meta: PropertyIndex, value: PropertyValue) -> Self {
-        MetadataChange {id, meta, value}
+        MetadataChange { id, meta, value }
     }
 }
 
@@ -115,7 +108,9 @@ pub unsafe extern "C" fn metadatachange_get_meta(meta: *const MetadataChange) ->
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn metadatachange_get_value(meta: *const MetadataChange) -> *const PropertyValue {
+pub unsafe extern "C" fn metadatachange_get_value(
+    meta: *const MetadataChange,
+) -> *const PropertyValue {
     &(*meta).value
 }
 
@@ -146,9 +141,9 @@ pub enum LibNotification {
 impl Drop for LibNotification {
     fn drop(&mut self) {
         match *self {
-            LibNotification::FolderContentQueried(mut c) |
-            LibNotification::KeywordContentQueried(mut c) => {
-                unsafe { c.destruct(); }
+            LibNotification::FolderContentQueried(mut c)
+            | LibNotification::KeywordContentQueried(mut c) => unsafe {
+                c.destruct();
             },
             _ => (),
         }
@@ -158,11 +153,18 @@ impl Drop for LibNotification {
 /// Send a notification for the file status change.
 /// Return `false` if sending failed.
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notify_filestatus_changed(channel: *const LcChannel,
-                                                           id: LibraryId,
-                                                           status: FileStatus) -> bool {
-    if let Err(err) = (*channel).0.clone().send(LibNotification::FileStatusChanged(
-        FileStatusChange{id, status})) {
+pub unsafe extern "C" fn engine_library_notify_filestatus_changed(
+    channel: *const LcChannel,
+    id: LibraryId,
+    status: FileStatus,
+) -> bool {
+    if let Err(err) = (*channel)
+        .0
+        .clone()
+        .send(LibNotification::FileStatusChanged(FileStatusChange {
+            id,
+            status,
+        })) {
         err_out!("Error sending notification: {}", err);
         return false;
     }
@@ -176,7 +178,9 @@ pub unsafe extern "C" fn engine_library_notification_delete(n: *mut LibNotificat
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_type(n: *const LibNotification) -> NotificationType {
+pub unsafe extern "C" fn engine_library_notification_type(
+    n: *const LibNotification,
+) -> NotificationType {
     match n.as_ref() {
         Some(&LibNotification::AddedFile) => NotificationType::ADDED_FILE,
         Some(&LibNotification::AddedFiles) => NotificationType::ADDED_FILES,
@@ -189,8 +193,9 @@ pub unsafe extern "C" fn engine_library_notification_type(n: *const LibNotificat
         Some(&LibNotification::FolderCounted(_)) => NotificationType::FOLDER_COUNTED,
         Some(&LibNotification::FolderCountChanged(_)) => NotificationType::FOLDER_COUNT_CHANGE,
         Some(&LibNotification::FolderDeleted(_)) => NotificationType::FOLDER_DELETED,
-        Some(&LibNotification::KeywordContentQueried(_)) =>
-            NotificationType::KEYWORD_CONTENT_QUERIED,
+        Some(&LibNotification::KeywordContentQueried(_)) => {
+            NotificationType::KEYWORD_CONTENT_QUERIED
+        }
         Some(&LibNotification::KeywordCounted(_)) => NotificationType::KEYWORD_COUNTED,
         Some(&LibNotification::KeywordCountChanged(_)) => NotificationType::KEYWORD_COUNT_CHANGE,
         Some(&LibNotification::LabelChanged(_)) => NotificationType::LABEL_CHANGED,
@@ -203,9 +208,10 @@ pub unsafe extern "C" fn engine_library_notification_type(n: *const LibNotificat
     }
 }
 
-
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_id(n: *const LibNotification) -> LibraryId {
+pub unsafe extern "C" fn engine_library_notification_get_id(
+    n: *const LibNotification,
+) -> LibraryId {
     match n.as_ref() {
         Some(&LibNotification::MetadataChanged(ref changed)) => changed.id,
         Some(&LibNotification::FolderDeleted(id)) => id,
@@ -216,84 +222,98 @@ pub unsafe extern "C" fn engine_library_notification_get_id(n: *const LibNotific
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_label(n: *const LibNotification) -> *const Label {
+pub unsafe extern "C" fn engine_library_notification_get_label(
+    n: *const LibNotification,
+) -> *const Label {
     match n.as_ref() {
-        Some(&LibNotification::AddedLabel(ref l)) |
-        Some(&LibNotification::LabelChanged(ref l)) => l,
+        Some(&LibNotification::AddedLabel(ref l)) | Some(&LibNotification::LabelChanged(ref l)) => {
+            l
+        }
         _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_filemoved(n: *const LibNotification) -> *const 
FileMove {
+pub unsafe extern "C" fn engine_library_notification_get_filemoved(
+    n: *const LibNotification,
+) -> *const FileMove {
     match n.as_ref() {
         Some(&LibNotification::FileMoved(ref m)) => m,
-        _ => unreachable!()
+        _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_filestatus(n: *const LibNotification) -> FileStatus 
{
+pub unsafe extern "C" fn engine_library_notification_get_filestatus(
+    n: *const LibNotification,
+) -> FileStatus {
     match n.as_ref() {
         Some(&LibNotification::FileStatusChanged(ref s)) => s.status,
-        _ => unreachable!()
+        _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_libmetadata(n: *const LibNotification) -> *const 
LibMetadata {
+pub unsafe extern "C" fn engine_library_notification_get_libmetadata(
+    n: *const LibNotification,
+) -> *const LibMetadata {
     match n.as_ref() {
         Some(&LibNotification::MetadataQueried(ref m)) => m,
-        _ => unreachable!()
+        _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_count(n: *const LibNotification) -> *const Count {
+pub unsafe extern "C" fn engine_library_notification_get_count(
+    n: *const LibNotification,
+) -> *const Count {
     match n.as_ref() {
-        Some(&LibNotification::FolderCountChanged(ref c)) |
-        Some(&LibNotification::FolderCounted(ref c)) |
-        Some(&LibNotification::KeywordCountChanged(ref c)) |
-        Some(&LibNotification::KeywordCounted(ref c)) =>
-            c,
-        _ => unreachable!()
+        Some(&LibNotification::FolderCountChanged(ref c))
+        | Some(&LibNotification::FolderCounted(ref c))
+        | Some(&LibNotification::KeywordCountChanged(ref c))
+        | Some(&LibNotification::KeywordCounted(ref c)) => c,
+        _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_metadatachange(n: *const LibNotification) -> *const 
MetadataChange {
+pub unsafe extern "C" fn engine_library_notification_get_metadatachange(
+    n: *const LibNotification,
+) -> *const MetadataChange {
     match n.as_ref() {
         Some(&LibNotification::MetadataChanged(ref c)) => c,
-        _ => unreachable!()
+        _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_libfolder(n: *const LibNotification) -> *const 
LibFolder {
+pub unsafe extern "C" fn engine_library_notification_get_libfolder(
+    n: *const LibNotification,
+) -> *const LibFolder {
     match n.as_ref() {
         Some(&LibNotification::AddedFolder(ref f)) => f,
-        _ => unreachable!()
+        _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_keyword(n: *const LibNotification) -> *const 
Keyword {
+pub unsafe extern "C" fn engine_library_notification_get_keyword(
+    n: *const LibNotification,
+) -> *const Keyword {
     match n.as_ref() {
         Some(&LibNotification::AddedKeyword(ref f)) => f,
-        _ => unreachable!()
+        _ => unreachable!(),
     }
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn engine_library_notification_get_content(n: *const LibNotification) -> *const 
Content {
+pub unsafe extern "C" fn engine_library_notification_get_content(
+    n: *const LibNotification,
+) -> *const Content {
     match n.as_ref() {
-        Some(&LibNotification::FolderContentQueried(ref c)) |
-        Some(&LibNotification::KeywordContentQueried(ref c)) => {
-            c
-        },
-        _ => {
-            unreachable!()
-        }
+        Some(&LibNotification::FolderContentQueried(ref c))
+        | Some(&LibNotification::KeywordContentQueried(ref c)) => c,
+        _ => unreachable!(),
     }
 }
 
@@ -303,12 +323,10 @@ use libc::c_void;
 #[cfg(test)]
 impl Content {
     pub unsafe fn new(_: LibraryId) -> Self {
-        Content{}
+        Content {}
     }
 
-    pub unsafe fn push(&mut self, _: *mut c_void) {
-    }
+    pub unsafe fn push(&mut self, _: *mut c_void) {}
 
-    pub unsafe fn destruct(&self) {
-    }
+    pub unsafe fn destruct(&self) {}
 }
diff --git a/crates/npc-engine/src/library/op.rs b/crates/npc-engine/src/library/op.rs
index 908e165..ff6055d 100644
--- a/crates/npc-engine/src/library/op.rs
+++ b/crates/npc-engine/src/library/op.rs
@@ -25,12 +25,14 @@ use crate::db::Library;
 type Function = dyn Fn(&Library) -> bool + Send + Sync + 'static;
 
 pub struct Op {
-    op: Arc<Function>
+    op: Arc<Function>,
 }
 
 impl Op {
     pub fn new<F>(f: F) -> Op
-        where F: Fn(&Library) -> bool + Send + Sync + 'static {
+    where
+        F: Fn(&Library) -> bool + Send + Sync + 'static,
+    {
         Op { op: Arc::new(f) }
     }
 


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