Add pagination to search results.

Move to shared definition of json requests between client/server.
This commit is contained in:
2023-03-09 18:04:55 -08:00
parent f16860dd09
commit eba362a7f2
10 changed files with 162 additions and 34 deletions

View File

@@ -478,8 +478,19 @@ impl Notmuch {
self.run_notmuch(std::iter::empty::<&str>())
}
pub fn search(&self, query: &str) -> Result<SearchSummary, NotmuchError> {
let res = self.run_notmuch(["search", "--format=json", "--limit=20", query])?;
pub fn search(
&self,
query: &str,
offset: usize,
limit: usize,
) -> Result<SearchSummary, NotmuchError> {
let res = self.run_notmuch([
"search",
"--format=json",
&format!("--offset={offset}"),
&format!("--limit={limit}"),
query,
])?;
Ok(serde_json::from_slice(&res)?)
}