[niepce] rust+npc-engine+npc-fwk: run cargo fmt



commit 5497df151f4594dac9b1309e5c466d52bfd85a69
Author: Hubert Figuière <hub figuiere net>
Date:   Sun Jan 12 23:23:06 2020 -0500

    rust+npc-engine+npc-fwk: run cargo fmt

 crates/npc-engine/src/db/libmetadata.rs       | 38 ++++++++++-------
 crates/npc-engine/src/db/library.rs           | 60 +++++++++++++++++----------
 crates/npc-engine/src/library/commands.rs     | 12 ++++--
 crates/npc-engine/src/library/notification.rs |  5 ++-
 crates/npc-fwk/src/utils/exempi.rs            | 36 ++++++++--------
 crates/npc-fwk/src/utils/exiv2.rs             | 32 +++++++-------
 6 files changed, 109 insertions(+), 74 deletions(-)
---
diff --git a/crates/npc-engine/src/db/libmetadata.rs b/crates/npc-engine/src/db/libmetadata.rs
index 567546a..e2a43fc 100644
--- a/crates/npc-engine/src/db/libmetadata.rs
+++ b/crates/npc-engine/src/db/libmetadata.rs
@@ -140,7 +140,8 @@ impl LibMetadata {
                                     "x-default",
                                     s,
                                     exempi::PROP_NONE,
-                                ).is_ok();
+                                )
+                                .is_ok();
                         }
                     } else {
                         return true;
@@ -161,7 +162,8 @@ impl LibMetadata {
                                 exempi::PROP_VALUE_IS_ARRAY,
                                 s,
                                 exempi::PROP_NONE,
-                            ).is_err()
+                            )
+                            .is_err()
                         {
                             err_out!("Error appending array item {} in property {}", &s, &ix.ns);
                             return false;
@@ -195,18 +197,26 @@ impl LibMetadata {
         for prop_id in propset {
             let prop_id_np: Np = unsafe { transmute(*prop_id) };
             match prop_id_np {
-                Np::NpXmpRatingProp => if let Some(rating) = self.xmp.rating() {
-                    props.set_value(*prop_id, PropertyValue::Int(rating));
-                },
-                Np::NpXmpLabelProp => if let Some(label) = self.xmp.label() {
-                    props.set_value(*prop_id, PropertyValue::String(label));
-                },
-                Np::NpTiffOrientationProp => if let Some(orientation) = self.xmp.orientation() {
-                    props.set_value(*prop_id, PropertyValue::Int(orientation));
-                },
-                Np::NpExifDateTimeOriginalProp => if let Some(date) = self.xmp.creation_date() {
-                    props.set_value(*prop_id, PropertyValue::Date(date));
-                },
+                Np::NpXmpRatingProp => {
+                    if let Some(rating) = self.xmp.rating() {
+                        props.set_value(*prop_id, PropertyValue::Int(rating));
+                    }
+                }
+                Np::NpXmpLabelProp => {
+                    if let Some(label) = self.xmp.label() {
+                        props.set_value(*prop_id, PropertyValue::String(label));
+                    }
+                }
+                Np::NpTiffOrientationProp => {
+                    if let Some(orientation) = self.xmp.orientation() {
+                        props.set_value(*prop_id, PropertyValue::Int(orientation));
+                    }
+                }
+                Np::NpExifDateTimeOriginalProp => {
+                    if let Some(date) = self.xmp.creation_date() {
+                        props.set_value(*prop_id, PropertyValue::Date(date));
+                    }
+                }
                 Np::NpIptcKeywordsProp => {
                     let mut iter = exempi::XmpIterator::new(
                         &self.xmp.xmp,
diff --git a/crates/npc-engine/src/db/library.rs b/crates/npc-engine/src/db/library.rs
index 2968e71..fe85189 100644
--- a/crates/npc-engine/src/db/library.rs
+++ b/crates/npc-engine/src/db/library.rs
@@ -194,11 +194,13 @@ impl Library {
                 "INSERT INTO admin (key, value) \
                  VALUES ('version', ?1)",
                 &[&DB_SCHEMA_VERSION],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute(
                 "CREATE TABLE vaults (id INTEGER PRIMARY KEY, path TEXT)",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute(
                 "CREATE TABLE folders (id INTEGER PRIMARY KEY,\
                  path TEXT, name TEXT, \
@@ -208,7 +210,8 @@ impl Library {
                  expanded INTEGER DEFAULT 0, \
                  parent_id INTEGER)",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             // Version 9
             conn.execute(
                 "CREATE TRIGGER folder_delete_trigger AFTER DELETE ON folders \
@@ -216,14 +219,16 @@ impl Library {
                  DELETE FROM files WHERE parent_id = old.id; \
                  END",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             //
             let trash_type = libfolder::FolderVirtualType::TRASH as i32;
             conn.execute(
                 "insert into folders (name, locked, virtual, parent_id, path) \
                  values (?1, 1, ?2, 0, '')",
                 &[&"Trash", &trash_type],
-            ).unwrap();
+            )
+            .unwrap();
 
             conn.execute(
                 "CREATE TABLE files (id INTEGER PRIMARY KEY,\
@@ -235,19 +240,22 @@ impl Library {
                  xmp TEXT, xmp_date INTEGER, xmp_file INTEGER,\
                  jpeg_file INTEGER)",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute(
                 "CREATE TABLE fsfiles (id INTEGER PRIMARY KEY,\
                  path TEXT)",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             // version = 7
             conn.execute(
                 "CREATE TABLE sidecars (file_id INTEGER,\
                  fsfile_id INTEGER, type INTEGER, ext TEXT NOT NULL,\
                  UNIQUE(file_id, fsfile_id))",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute_batch(
                 "BEGIN; \
                  CREATE TRIGGER pre_file_delete_trigger BEFORE DELETE ON files \
@@ -261,30 +269,35 @@ impl Library {
                  DELETE FROM keywording WHERE file_id = old.id; \
                  END; \
                  COMMIT;",
-            ).unwrap();
+            )
+            .unwrap();
             //
             conn.execute(
                 "CREATE TABLE keywords (id INTEGER PRIMARY KEY,\
                  keyword TEXT, parent_id INTEGER DEFAULT 0)",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute(
                 "CREATE TABLE keywording (file_id INTEGER,\
                  keyword_id INTEGER, UNIQUE(file_id, keyword_id))",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute(
                 "CREATE TRIGGER keyword_delete_trigger AFTER DELETE ON keywords \
                  BEGIN \
                  DELETE FROM keywording WHERE keyword_id = old.id; \
                  END;",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute(
                 "CREATE TABLE labels (id INTEGER PRIMARY KEY,\
                  name TEXT, color TEXT)",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute("CREATE TABLE xmp_update_queue (id INTEGER UNIQUE)", &[])
                 .unwrap();
             conn.execute(
@@ -293,7 +306,8 @@ impl Library {
                  UPDATE files SET mod_date = strftime('%s','now');\
                  END",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
             conn.execute(
                 "CREATE TRIGGER xmp_update_trigger UPDATE OF xmp ON files \
                  BEGIN \
@@ -301,7 +315,8 @@ impl Library {
                  SELECT rewrite_xmp();\
                  END",
                 &[],
-            ).unwrap();
+            )
+            .unwrap();
 
             if self.notify(LibNotification::LibCreated).is_err() {
                 err_out!("Error sending LibCreated notification");
@@ -755,7 +770,8 @@ impl Library {
             if self
                 .notify(LibNotification::AddedKeyword(Keyword::new(
                     keyword_id, keyword,
-                ))).is_err()
+                )))
+                .is_err()
             {
                 err_out!("Failed to send AddedKeyword notification");
             }
@@ -886,12 +902,14 @@ impl Library {
                 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)?;
+                    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),
                 }
             }
diff --git a/crates/npc-engine/src/library/commands.rs b/crates/npc-engine/src/library/commands.rs
index c5d6efb..3fcf58f 100644
--- a/crates/npc-engine/src/library/commands.rs
+++ b/crates/npc-engine/src/library/commands.rs
@@ -215,7 +215,8 @@ pub fn cmd_set_metadata(lib: &Library, id: LibraryId, meta: Np, value: &Property
                     id,
                     meta as u32,
                     value.clone(),
-                ))).is_err()
+                )))
+                .is_err()
             {
                 err_out!("Failed to notify MetadataChange");
             }
@@ -335,7 +336,8 @@ pub fn cmd_move_file_to_folder(
                     file: file_id,
                     from,
                     to,
-                })).is_err()
+                }))
+                .is_err()
             {
                 err_out!("Failed to notify FileMoved");
             }
@@ -343,7 +345,8 @@ pub fn cmd_move_file_to_folder(
                 .notify(LibNotification::FolderCountChanged(Count {
                     id: from,
                     count: -1,
-                })).is_err()
+                }))
+                .is_err()
             {
                 err_out!("Failed to notify FileMoved");
             }
@@ -351,7 +354,8 @@ pub fn cmd_move_file_to_folder(
                 .notify(LibNotification::FolderCountChanged(Count {
                     id: to,
                     count: 1,
-                })).is_err()
+                }))
+                .is_err()
             {
                 err_out!("Failed to notify FileMoved");
             }
diff --git a/crates/npc-engine/src/library/notification.rs b/crates/npc-engine/src/library/notification.rs
index 0348559..e7d6e03 100644
--- a/crates/npc-engine/src/library/notification.rs
+++ b/crates/npc-engine/src/library/notification.rs
@@ -17,9 +17,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+use super::queriedcontent::QueriedContent;
 use crate::db::libfile::FileStatus;
 use crate::db::{Keyword, Label, LibFolder, LibMetadata, LibraryId};
-use super::queriedcontent::QueriedContent;
 use npc_fwk::base::PropertyIndex;
 use npc_fwk::toolkit::PortableChannel;
 use npc_fwk::PropertyValue;
@@ -142,7 +142,8 @@ pub unsafe extern "C" fn engine_library_notify_filestatus_changed(
         .send(LibNotification::FileStatusChanged(FileStatusChange {
             id,
             status,
-        })) {
+        }))
+    {
         err_out!("Error sending notification: {}", err);
         return false;
     }
diff --git a/crates/npc-fwk/src/utils/exempi.rs b/crates/npc-fwk/src/utils/exempi.rs
index 4fd4e26..30f269e 100644
--- a/crates/npc-fwk/src/utils/exempi.rs
+++ b/crates/npc-fwk/src/utils/exempi.rs
@@ -263,14 +263,16 @@ impl XmpMeta {
                     continue;
                 }
 
-                if !dest.xmp.has_property(schema.to_str(), name.to_str()) && dest
-                    .xmp
-                    .set_property(
-                        schema.to_str(),
-                        name.to_str(),
-                        value.to_str(),
-                        exempi::PROP_NONE,
-                    ).is_err()
+                if !dest.xmp.has_property(schema.to_str(), name.to_str())
+                    && dest
+                        .xmp
+                        .set_property(
+                            schema.to_str(),
+                            name.to_str(),
+                            value.to_str(),
+                            exempi::PROP_NONE,
+                        )
+                        .is_err()
                 {
                     err_out!("Can set property {}", name);
                 }
@@ -336,11 +338,10 @@ impl XmpMeta {
 
     pub fn creation_date(&self) -> Option<DateTime<Utc>> {
         let mut flags: exempi::PropFlags = exempi::PropFlags::empty();
-        let xmpstring = try_opt!(
-            self.xmp
-                .get_property(NS_EXIF, "DateTimeOriginal", &mut flags)
-                .ok()
-        );
+        let xmpstring = try_opt!(self
+            .xmp
+            .get_property(NS_EXIF, "DateTimeOriginal", &mut flags)
+            .ok());
         let date = try_opt!(DateTime::parse_from_rfc3339(xmpstring.to_str()).ok());
 
         Some(date.with_timezone(&Utc))
@@ -348,11 +349,10 @@ impl XmpMeta {
 
     pub fn creation_date_str(&self) -> Option<String> {
         let mut flags: exempi::PropFlags = exempi::PropFlags::empty();
-        let xmpstring = try_opt!(
-            self.xmp
-                .get_property(NS_EXIF, "DateTimeOriginal", &mut flags)
-                .ok()
-        );
+        let xmpstring = try_opt!(self
+            .xmp
+            .get_property(NS_EXIF, "DateTimeOriginal", &mut flags)
+            .ok());
         Some(String::from(xmpstring.to_str()))
     }
 
diff --git a/crates/npc-fwk/src/utils/exiv2.rs b/crates/npc-fwk/src/utils/exiv2.rs
index c4ddd12..7b698b3 100644
--- a/crates/npc-fwk/src/utils/exiv2.rs
+++ b/crates/npc-fwk/src/utils/exiv2.rs
@@ -415,22 +415,24 @@ pub fn xmp_from_exiv2<S: AsRef<OsStr>>(file: S) -> Option<XmpMeta> {
                                     }
                                 }
                             }
-                            _ => if let Some(value) = meta.get_tag_rational(&tag) {
-                                let value_str = format!("{}/{}", value.numer(), value.denom());
-                                if let Err(err) = xmp.set_property(
-                                    xmp_prop.0,
-                                    xmp_prop.1,
-                                    &value_str,
-                                    exempi::PROP_NONE,
-                                ) {
-                                    err_out!(
-                                        "Error setting property {} {}: {:?}",
-                                        &xmp_prop.0,
-                                        &xmp_prop.1,
-                                        &err
-                                    );
+                            _ => {
+                                if let Some(value) = meta.get_tag_rational(&tag) {
+                                    let value_str = format!("{}/{}", value.numer(), value.denom());
+                                    if let Err(err) = xmp.set_property(
+                                        xmp_prop.0,
+                                        xmp_prop.1,
+                                        &value_str,
+                                        exempi::PROP_NONE,
+                                    ) {
+                                        err_out!(
+                                            "Error setting property {} {}: {:?}",
+                                            &xmp_prop.0,
+                                            &xmp_prop.1,
+                                            &err
+                                        );
+                                    }
                                 }
-                            },
+                            }
                         },
                         Ok(rexiv2::TagType::Comment) => {
                             if let Ok(value) = meta.get_tag_string(&tag) {


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