pub struct Store { /* private fields */ }Implementations§
Source§impl Store
impl Store
Sourcepub fn default_path() -> Result<PathBuf>
pub fn default_path() -> Result<PathBuf>
$RGET_DB overrides the location — used by the test suite so tests
never touch a developer’s real download list.
pub fn open_default() -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
pub fn open_in_memory() -> Result<Self>
pub fn path(&self) -> &Path
Sourcepub fn get_meta(&self, key: &str) -> Result<Option<String>>
pub fn get_meta(&self, key: &str) -> Result<Option<String>>
Read a persisted setting. Settings live in the same database as the downloads so there is exactly one piece of state to back up or delete.
pub fn set_meta(&self, key: &str, value: &str) -> Result<()>
pub fn clear_meta(&self, key: &str) -> Result<()>
pub fn get(&self, id: &str) -> Result<Option<DownloadRecord>>
Sourcepub fn resolve_id(&self, prefix: &str) -> Result<DownloadRecord>
pub fn resolve_id(&self, prefix: &str) -> Result<DownloadRecord>
Resolve a user-typed short id. Ambiguity is an error, not a coin flip.
Sourcepub fn find_for(
&self,
url: &str,
destination: &Path,
) -> Result<Option<DownloadRecord>>
pub fn find_for( &self, url: &str, destination: &Path, ) -> Result<Option<DownloadRecord>>
Find an existing download for this URL landing at this destination. Matching on both is what makes resume automatic (PRD §5) without accidentally resuming into a different file.
Sourcepub fn find_by_destination(
&self,
destination: &Path,
) -> Result<Option<DownloadRecord>>
pub fn find_by_destination( &self, destination: &Path, ) -> Result<Option<DownloadRecord>>
Any download already targeting this destination, regardless of URL — used to refuse clobbering an unrelated in-flight download.
pub fn list(&self) -> Result<Vec<DownloadRecord>>
pub fn list_resumable(&self) -> Result<Vec<DownloadRecord>>
pub fn insert(&self, rec: &DownloadRecord) -> Result<()>
Sourcepub fn update_remote_metadata(&self, rec: &DownloadRecord) -> Result<()>
pub fn update_remote_metadata(&self, rec: &DownloadRecord) -> Result<()>
Refresh the validators and shape we learned from a fresh probe.
pub fn set_status( &self, id: &str, status: Status, error: Option<&str>, ) -> Result<()>
Sourcepub fn replace_ranges(&self, id: &str, ranges: &[RangeRecord]) -> Result<()>
pub fn replace_ranges(&self, id: &str, ranges: &[RangeRecord]) -> Result<()>
Install a fresh range plan, replacing any previous one, atomically.
pub fn load_ranges(&self, id: &str) -> Result<Vec<RangeRecord>>
Sourcepub fn commit_progress(
&self,
id: &str,
updates: &[ProgressUpdate],
) -> Result<u64>
pub fn commit_progress( &self, id: &str, updates: &[ProgressUpdate], ) -> Result<u64>
The one durable-progress entry point. Called by the committer after
fdatasync of the destination file, never before.
One transaction, so a kill at any instruction leaves either the whole batch or none of it (PRD Invariant 7).
Sourcepub fn apply_split(
&self,
id: &str,
shrunk: RangeRecord,
added: RangeRecord,
) -> Result<()>
pub fn apply_split( &self, id: &str, shrunk: RangeRecord, added: RangeRecord, ) -> Result<()>
Record a split: the victim shrinks and the remainder becomes a new range, in one transaction so Invariant 3 (no gaps) always holds on disk.
Sourcepub fn reset(&self, id: &str) -> Result<()>
pub fn reset(&self, id: &str) -> Result<()>
Drop all progress for a download but keep its identity (--restart).