From 7eb92212330ee87c989da25181c8362dfc6348ec Mon Sep 17 00:00:00 2001 From: ph0llux Date: Sun, 15 Dec 2024 15:24:22 +0100 Subject: [PATCH] added option to ZffReader to list decrypted objects only --- src/lib/io/zffreader/mod.rs | 14 ++++++++++++++ src/lib/mod.rs | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/io/zffreader/mod.rs b/src/lib/io/zffreader/mod.rs index afd2c77..4c774ee 100644 --- a/src/lib/io/zffreader/mod.rs +++ b/src/lib/io/zffreader/mod.rs @@ -261,6 +261,20 @@ impl ZffReader { Ok(map) } + /// Same as list_objects, but ignores encrypted objects + pub fn list_decrypted_objects(&self) -> BTreeMap { + let mut map = BTreeMap::new(); + for (k, v) in &self.object_reader { + match v { + ZffObjectReader::Encrypted(_) => (), + ZffObjectReader::Physical(_) => { map.insert(*k, ObjectType::Physical); }, + ZffObjectReader::Logical(_) => { map.insert(*k, ObjectType::Logical); }, + ZffObjectReader::Virtual(_) => { map.insert(*k, ObjectType::Virtual); }, + }; + }; + map + } + /// Sets an appropriate object as active to read or seek from this object. /// # Error /// This method fails, if the appropriate object number not exists in this zff container. diff --git a/src/lib/mod.rs b/src/lib/mod.rs index 1ca713b..c114ec2 100644 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -22,7 +22,8 @@ pub mod io; pub mod helper; mod hashing; mod compression; -mod encryption; +/// Contains various functions, methods and traits to handle encryption in zff. +pub mod encryption; mod traits; mod error; mod signatures;