ANW-14 GET /notes/<folder>/ directory listing
This commit is contained in:
parent
e1fe1dcb4e
commit
da2dfbbd6d
2 changed files with 235 additions and 8 deletions
14
src/store.rs
14
src/store.rs
|
|
@ -90,6 +90,20 @@ impl NoteStore {
|
|||
.len()
|
||||
}
|
||||
|
||||
/// Run `f` with a shared reference to the underlying map. The read lock
|
||||
/// is held for the call; do not run anything that might block on a
|
||||
/// writer here. Used by the folder-listing handler in [`crate::http`].
|
||||
///
|
||||
/// # Panics
|
||||
/// Panics if the inner `RwLock` has been poisoned.
|
||||
pub fn with_read<F, R>(&self, f: F) -> R
|
||||
where
|
||||
F: FnOnce(&BTreeMap<String, Note>) -> R,
|
||||
{
|
||||
let guard = self.inner.read().expect("note_store: read lock poisoned");
|
||||
f(&guard)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue