Skip to main content

DownloadOperation

Struct DownloadOperation 

Source
pub struct DownloadOperation(/* private fields */);
Expand description

An in-progress or finished download.

Implementations§

Source§

impl DownloadOperation

Source

pub fn uri(&self) -> String

Returns the URI the content is being downloaded from.

Source

pub fn content_disposition(&self) -> String

Returns the Content-Disposition header value from the download’s HTTP response, if any.

Source

pub fn mime_type(&self) -> String

Returns the MIME type of the downloaded content.

Source

pub fn total_bytes_to_receive(&self) -> i64

Returns the expected total size of the download in bytes, or 0 if it is unknown.

Source

pub fn bytes_received(&self) -> i64

Returns the number of bytes received so far.

Source

pub fn result_file_path(&self) -> String

Returns the absolute path the download is being written to.

Source

pub fn state(&self) -> DownloadState

Returns the current DownloadState.

Source

pub fn interrupt_reason(&self) -> DownloadInterruptReason

Returns why the download was interrupted, or DownloadInterruptReason::None if it has not been interrupted.

Source

pub fn can_resume(&self) -> bool

Returns true if an interrupted download can be resumed.

Source

pub fn cancel(&self) -> Result<()>

Cancels the download. The file is deleted if it was not yet complete.

Source

pub fn pause(&self) -> Result<()>

Pauses the download. It stays in progress until resumed or canceled.

Source

pub fn resume(&self) -> Result<()>

Resumes a paused or interrupted download.

Source

pub fn on_bytes_received_changed<F: FnMut(DownloadOperation) + 'static>( &self, handler: F, ) -> Result<EventRegistration>

Subscribes to the bytes-received-changed event, raised as the download makes progress. The handler receives this operation so it can read the updated bytes_received.

Source

pub fn on_state_changed<F: FnMut(DownloadOperation) + 'static>( &self, handler: F, ) -> Result<EventRegistration>

Subscribes to the state-changed event, raised when the download’s state changes (for example to completed or interrupted). The handler receives this operation.

Trait Implementations§

Source§

impl Clone for DownloadOperation

Source§

fn clone(&self) -> DownloadOperation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.