Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }

Implementations§

Source§

impl Store

Source

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.

Source

pub fn open_default() -> Result<Self>

Source

pub fn open(path: &Path) -> Result<Self>

Source

pub fn open_in_memory() -> Result<Self>

Source

pub fn path(&self) -> &Path

Source

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.

Source

pub fn set_meta(&self, key: &str, value: &str) -> Result<()>

Source

pub fn clear_meta(&self, key: &str) -> Result<()>

Source

pub fn get(&self, id: &str) -> Result<Option<DownloadRecord>>

Source

pub fn resolve_id(&self, prefix: &str) -> Result<DownloadRecord>

Resolve a user-typed short id. Ambiguity is an error, not a coin flip.

Source

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.

Source

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.

Source

pub fn list(&self) -> Result<Vec<DownloadRecord>>

Source

pub fn list_resumable(&self) -> Result<Vec<DownloadRecord>>

Source

pub fn insert(&self, rec: &DownloadRecord) -> Result<()>

Source

pub fn update_remote_metadata(&self, rec: &DownloadRecord) -> Result<()>

Refresh the validators and shape we learned from a fresh probe.

Source

pub fn set_status( &self, id: &str, status: Status, error: Option<&str>, ) -> Result<()>

Source

pub fn replace_ranges(&self, id: &str, ranges: &[RangeRecord]) -> Result<()>

Install a fresh range plan, replacing any previous one, atomically.

Source

pub fn load_ranges(&self, id: &str) -> Result<Vec<RangeRecord>>

Source

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).

Source

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.

Source

pub fn reset(&self, id: &str) -> Result<()>

Drop all progress for a download but keep its identity (--restart).

Source

pub fn forget(&self, id: &str) -> Result<()>

Forget metadata. Never touches the downloaded file (PRD §20).

Source

pub fn mint_id(&self, seed: &str) -> Result<String>

Mint a short, human-typeable id that is free in this database.

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more