Skip to content

Commit

Permalink
Update rust (#68)
Browse files Browse the repository at this point in the history
* Update rust

* Add todo

* Use return impl

* Fix clippy warnings
  • Loading branch information
quambene authored Jan 1, 2024
1 parent 6585239 commit 97020ee
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.72"
channel = "1.75"
profile = "default"
4 changes: 2 additions & 2 deletions src/bookmark_reader/chromium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl Chromium {
}
}
Value::Array(arr) => {
for (_index, val) in arr.iter().enumerate() {
for val in arr {
Self::traverse_json(val, source_bookmarks, source);
}
}
Expand All @@ -81,7 +81,7 @@ impl Chromium {
}
}
Value::Array(arr) => {
for (_index, val) in arr.iter().enumerate() {
for val in arr {
Self::traverse_children(val, source_bookmarks, source);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/bookmark_reader/firefox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Firefox {
}
}
Value::Array(arr) => {
for (_index, val) in arr.iter().enumerate() {
for val in arr {
Self::traverse_json(val, source_bookmarks, source);
}
}
Expand All @@ -84,7 +84,7 @@ impl Firefox {
}
}
Value::Array(arr) => {
for (_index, val) in arr.iter().enumerate() {
for val in arr {
Self::traverse_children(val, source_bookmarks, source);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/bookmarks/target_bookmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl TargetBookmarks {
let url = entry.key().clone();
let target_bookmark = entry.into_mut();
debug!("Overwrite duplicate target bookmark: {}", url);
// TODO: use existing bookmark id and bookmark urls
*target_bookmark = bookmark;
}
Entry::Vacant(entry) => {
Expand Down
8 changes: 4 additions & 4 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub trait Caching {

/// Open the cached file for a bookmark.
// TODO: return `Result<Option<impl Read>, anyhow::Error>` (see <https://github.com/rust-lang/rust/issues/91611>).
fn open(&self, bookmark: &TargetBookmark) -> Result<Option<File>, BogrepError>;
fn open(&self, bookmark: &TargetBookmark) -> Result<Option<impl Read>, BogrepError>;

/// Get the content of a bookmark from cache.
// TODO: make get async
Expand Down Expand Up @@ -153,7 +153,7 @@ impl Caching for Cache {
bookmark.cache_modes.contains(self.mode())
}

fn open(&self, bookmark: &TargetBookmark) -> Result<Option<File>, BogrepError> {
fn open(&self, bookmark: &TargetBookmark) -> Result<Option<impl Read>, BogrepError> {
let cache_path = self.bookmark_path(&bookmark.id);
debug!("Open website: {}", cache_path.display());

Expand Down Expand Up @@ -322,8 +322,8 @@ impl Caching for MockCache {
self.get(bookmark).unwrap().is_some()
}

fn open(&self, _bookmark: &TargetBookmark) -> Result<Option<File>, BogrepError> {
Ok(None)
fn open(&self, _bookmark: &TargetBookmark) -> Result<Option<impl Read>, BogrepError> {
Ok(None::<File>)
}

fn get(&self, bookmark: &TargetBookmark) -> Result<Option<String>, BogrepError> {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ async fn test_fetch_empty_cache() {
}

let cache_dir = temp_path.join("cache");
let entries = fs::read_dir(&cache_dir);
let entries = fs::read_dir(cache_dir);
assert!(entries.is_ok_and(|mut file| file.next().is_none()));

println!("Execute 'bogrep fetch'");
Expand Down

0 comments on commit 97020ee

Please sign in to comment.