pub enum StateError {
Open(Error),
Save(Error),
Decode(Error),
Encode(Error),
FileChanged {
local_file_id: FileId,
local_file_size: u64,
remote_file_id: FileId,
remote_file_size: u64,
},
Truncated {
actual_size: u64,
recorded_size: u64,
},
NotResumable(UrlInfo, Response),
NoUrl(PathBuf),
NotAPartFile(PathBuf),
}Expand description
Errors that can occur when an explicit resume
cannot continue an interrupted download.
These are surfaced through crate::Event::ResumeError so the caller is notified
instead of silently falling back to a full re-download.
Variants§
Open(Error)
Failed to open or read the .fd state file from disk.
This usually means the file is missing or unreadable (permission error, removed by another process, etc.).
Save(Error)
Failed to persist the .fd state file to disk.
The state was computed but could not be written (disk full, permission error, etc.).
Decode(Error)
Failed to deserialize the .fd state file.
The file was read but is not valid TOML, or its schema no longer matches
the current DownloadStateInner definition.
Encode(Error)
Failed to serialize the download state into the .fd state file.
The state could not be encoded as TOML (e.g. a field holds a value that has no valid TOML representation).
FileChanged
The remote file changed (size / etag / last-modified mismatch), so resuming would corrupt the output.
Truncated
The .part file is shorter than the progress recorded in the .fd, so
the recorded ranges no longer describe bytes that exist on disk.
Continuing would let the sink extend the file with zeros across the missing span and never fetch it, silently corrupting the output.
NotResumable(UrlInfo, Response)
The server does not support resumable (range) downloads.
NoUrl(PathBuf)
No URL is available to resume the download.
resume was called with url = None and the persisted .fd state file
carries no resolvable initial URL (it was missing, or written by an older
build that did not store one). A URL is required to re-resolve the
resource, so the call reports this error instead of silently falling back
to a full re-download.
NotAPartFile(PathBuf)
peek_resume 收到的 tmp_path 不是 .part 文件。
peek_resume 需要的是 .part 临时文件路径,其同名 .fd 才是保存的状态;
传入其他扩展名的路径属于参数错误,而非文件读取失败。
Trait Implementations§
Source§impl Debug for StateError
impl Debug for StateError
Source§impl Display for StateError
impl Display for StateError
Source§impl Error for StateError
impl Error for StateError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()