coven/handle_local_bytes.rs
1//! What this device keeps for the store, measured on request and as it
2//! changes (§17.8, §19.3, E8).
3
4use crate::*;
5
6impl CovenHandle {
7 /// One measurement of what the store keeps on this device. The cache's
8 /// counters, the partial downloads' sizes and the budgets come from one
9 /// read of the database; the store's directory is then walked for its own
10 /// files and the archives resets kept. The cache's bytes are counted by
11 /// its entries, so the walk leaves its folder out.
12 pub async fn local_bytes(&self) -> CovenResult<LocalBytes> {
13 Ok(self.database.local_bytes().await?)
14 }
15
16 /// The first measurement at once, then a new one after each write that
17 /// changes the cache's committed entries or a budget, and after each
18 /// `delete_discarded_devices`. Partial downloads are measured with each
19 /// but start none.
20 pub fn subscribe_local_bytes(&self) -> LocalBytesWatch {
21 self.database.subscribe_local_bytes()
22 }
23}
24
25#[cfg(test)]
26#[path = "handle_local_bytes_tests.rs"]
27mod tests;