pub struct Downloader { /* private fields */ }Expand description
简化的下载器
Implementations§
Source§impl Downloader
impl Downloader
Sourcepub fn with_config(config: DownloadConfig) -> Self
pub fn with_config(config: DownloadConfig) -> Self
使用指定配置创建下载器
§Panics
Panics if the HTTP client cannot be created (should not happen with valid configuration)
Sourcepub async fn download<P: AsRef<Path>>(
&self,
url: &str,
output_path: P,
progress_reporter: Option<ProgressReporter>,
) -> DownloadResult<()>
pub async fn download<P: AsRef<Path>>( &self, url: &str, output_path: P, progress_reporter: Option<ProgressReporter>, ) -> DownloadResult<()>
下载文件(支持分片下载和多线程)
§Errors
Returns an error if:
- Network request fails
- File I/O operations fail
- Download validation fails
- Server does not support range requests when chunked download is attempted
Sourcepub async fn get_file_size(&self, url: &str) -> DownloadResult<u64>
pub async fn get_file_size(&self, url: &str) -> DownloadResult<u64>
获取文件大小 获取文件大小
§Errors
Returns an error if:
- Network request fails
- Server does not provide content-length header
- Content-length value is invalid
Trait Implementations§
Source§impl Clone for Downloader
impl Clone for Downloader
Source§fn clone(&self) -> Downloader
fn clone(&self) -> Downloader
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Downloader
impl Debug for Downloader
Auto Trait Implementations§
impl Freeze for Downloader
impl !RefUnwindSafe for Downloader
impl Send for Downloader
impl Sync for Downloader
impl Unpin for Downloader
impl !UnwindSafe for Downloader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more