implement pagination totals info

This commit is contained in:
yggverse 2025-08-05 19:21:08 +03:00
parent 3b95561c08
commit a4ce8e29d5
5 changed files with 38 additions and 20 deletions

View file

@ -76,9 +76,10 @@ impl Storage {
sort_order: Option<(Sort, Order)>,
start: Option<usize>,
limit: Option<usize>,
) -> Result<Vec<Torrent>, String> {
) -> Result<(usize, Vec<Torrent>), String> {
let f = self.files(sort_order)?;
let l = limit.unwrap_or(f.len());
let t = f.len();
let l = limit.unwrap_or(t);
let mut b = Vec::with_capacity(l);
for file in f.into_iter().skip(start.unwrap_or_default()).take(l) {
if file
@ -163,7 +164,7 @@ impl Storage {
.into(),
})
}
Ok(b)
Ok((t, b))
}
// Helpers