Add public function to iterate over maildir
This commit is contained in:
parent
7f8ba1337b
commit
24427f6f65
1 changed files with 7 additions and 0 deletions
|
@ -110,6 +110,13 @@ pub fn maildir_iterator(mbox_path: String) -> Iterator(String) {
|
|||
|> iterator.map(read_file)
|
||||
}
|
||||
|
||||
// TODO: better error
|
||||
pub fn maildir_iterate(maildir_path: String) -> Iterator(#(String, String)) {
|
||||
case simplifile.get_files(maildir_path) {
|
||||
Ok(maillist) -> iterator.from_list(maillist) |> iterator.map(fn(path) { #(path, read_file(path)) })
|
||||
Error(_) -> #("", "") |> list.wrap |> iterator.from_list
|
||||
}
|
||||
}
|
||||
fn read_file(file_path: String) -> String {
|
||||
file_path
|
||||
|> simplifile.read
|
||||
|
|
Loading…
Reference in a new issue