From 1b6711fe109bc3a11cccdaa72d8be58c9187a2b4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 2 Dec 2015 11:41:49 +0100 Subject: [PATCH] Add StorageBackend::iter_ids() --- src/storage/backend.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/storage/backend.rs b/src/storage/backend.rs index 0b7dbe72..7c413b24 100644 --- a/src/storage/backend.rs +++ b/src/storage/backend.rs @@ -8,6 +8,7 @@ use std::vec::Vec; use std::fs::File as FSFile; use std::io::Read; use std::io::Write; +use std::vec::IntoIter; use glob::glob; use glob::Paths; @@ -61,6 +62,17 @@ impl StorageBackend { } } + pub fn iter_ids(&self, m: &Module) -> Option> + { + glob(&self.prefix_of_files_for_module(m)[..]).and_then(|globlist| { + let v = globlist.filter_map(Result::ok) + .map(|pbuf| from_pathbuf(&pbuf)) + .collect::>() + .into_iter(); + Ok(v) + }).ok() + } + /* * Write a file to disk. *