Fix usages of get_external_links()

This commit is contained in:
Matthias Beyer 2016-10-15 15:45:19 +02:00
parent db17b4f858
commit c229bb1575
2 changed files with 7 additions and 4 deletions

View file

@ -296,7 +296,7 @@ fn set_links_for_entry(store: &Store, matches: &ArgMatches, entry: &mut FileLock
fn list_links_for_entry(store: &Store, entry: &mut FileLockEntry) { fn list_links_for_entry(store: &Store, entry: &mut FileLockEntry) {
entry.get_external_links(store) entry.get_external_links(store)
.and_then(|links| { .and_then(|links| {
for (i, link) in links.iter().enumerate() { for (i, link) in links.enumerate() {
println!("{: <3}: {}", i, link); println!("{: <3}: {}", i, link);
} }
Ok(()) Ok(())

View file

@ -37,6 +37,7 @@ use libimagstore::store::Store;
use libimagstore::storeid::IntoStoreId; use libimagstore::storeid::IntoStoreId;
use libimagstore::store::FileLockEntry; use libimagstore::store::FileLockEntry;
use libimagentrylink::external::ExternalLinker; use libimagentrylink::external::ExternalLinker;
use libimagentrylink::external::iter::UrlIter;
use libimagentrylink::internal::InternalLinker; use libimagentrylink::internal::InternalLinker;
use libimagentrylink::internal::Link as StoreLink; use libimagentrylink::internal::Link as StoreLink;
use libimagerror::into::IntoError; use libimagerror::into::IntoError;
@ -105,7 +106,7 @@ impl<'a> BookmarkCollection<'a> {
.map_err_into(BEK::StoreReadError) .map_err_into(BEK::StoreReadError)
} }
pub fn links(&self) -> Result<Vec<Url>> { pub fn links(&self) -> Result<UrlIter> {
self.fle.get_external_links(&self.store).map_err_into(BEK::LinkError) self.fle.get_external_links(&self.store).map_err_into(BEK::LinkError)
} }
@ -126,11 +127,13 @@ impl<'a> BookmarkCollection<'a> {
.map_err_into(BEK::LinkError) .map_err_into(BEK::LinkError)
} }
pub fn get_links_matching(&self, r: Regex) -> Result<Vec<Link>> { pub fn get_links_matching(&self, r: Regex) -> Result<UrlIter> {
use std::result::Result as RResult;
self.get_external_links(self.store) self.get_external_links(self.store)
.map_err_into(BEK::LinkError) .map_err_into(BEK::LinkError)
.map(|v| { .map(|v| {
v.into_iter() v.filter_map(RResult::ok) // TODO: Do not ignore errors here
.map(Url::into_string) .map(Url::into_string)
.filter(|urlstr| r.is_match(&urlstr[..])) .filter(|urlstr| r.is_match(&urlstr[..]))
.map(Link::from) .map(Link::from)