pub trait DownloadExt: 'static {
Show 20 methods fn cancel(&self); fn allows_overwrite(&self) -> bool; fn destination(&self) -> Option<GString>; fn elapsed_time(&self) -> f64; fn estimated_progress(&self) -> f64; fn received_data_length(&self) -> u64; fn request(&self) -> Option<URIRequest>; fn response(&self) -> Option<URIResponse>; fn web_view(&self) -> Option<WebView>; fn set_allow_overwrite(&self, allowed: bool); fn set_destination(&self, uri: &str); fn connect_created_destination<F: Fn(&Self, &str) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_decide_destination<F: Fn(&Self, &str) -> bool + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_failed<F: Fn(&Self, &Error) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_finished<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_received_data<F: Fn(&Self, u64) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_allow_overwrite_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_destination_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_estimated_progress_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_response_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Trait containing all Download methods.

Implementors

Download

Required Methods

Cancels the download.

When the ongoing download operation is effectively cancelled the signal signal::Download::failed is emitted with DownloadError::CancelledByUser error.

Available on crate feature v2_6 only.

Returns the current value of the property::Download::allow-overwrite property.

Returns the current value of the property::Download::allow-overwrite property, which determines whether the download will overwrite an existing file on disk, or if it will fail if the destination already exists.

Returns

the current value of the property::Download::allow-overwrite property

Obtains the URI to which the downloaded file will be written.

You can connect to signal::Download::created-destination to make sure this method returns a valid destination.

Returns

the destination URI or None

Gets the elapsed time in seconds, including any fractional part.

If the download finished, had an error or was cancelled this is the time between its start and the event.

Returns

seconds since the download was started

Gets the value of the property::Download::estimated-progress property. Gets the value of the property::Download::estimated-progress property. You can monitor the estimated progress of the download operation by connecting to the notify::estimated-progress signal of self.

Returns

an estimate of the of the percent complete for a download as a range from 0.0 to 1.0.

Gets the length of the data already downloaded for self.

Gets the length of the data already downloaded for self in bytes.

Returns

the amount of bytes already downloaded.

Retrieves the URIRequest object that backs the download process.

Returns

the URIRequest of self

Retrieves the URIResponse object that backs the download process.

Retrieves the URIResponse object that backs the download process. This method returns None if called before the response is received from the server. You can connect to notify::response signal to be notified when the response is received.

Returns

the URIResponse, or None if the response hasn’t been received yet.

Get the WebView that initiated the download.

Returns

the WebView that initiated self, or None if self was not initiated by a WebView.

Available on crate feature v2_6 only.

Sets the property::Download::allow-overwrite property.

Sets the property::Download::allow-overwrite property, which determines whether the download may overwrite an existing file on disk, or if it will fail if the destination already exists.

allowed

the new value for the property::Download::allow-overwrite property

Sets the URI to which the downloaded file will be written.

This method should be called before the download transfer starts or it will not have any effect on the ongoing download operation. To set the destination using the filename suggested by the server connect to signal::Download::decide-destination signal and call set_destination(). If you want to set a fixed destination URI that doesn’t depend on the suggested filename you can connect to notify::response signal and call set_destination(). If signal::Download::decide-destination signal is not handled and destination URI is not set when the download transfer starts, the file will be saved with the filename suggested by the server in G_USER_DIRECTORY_DOWNLOAD directory.

uri

the destination URI

This signal is emitted after signal::Download::decide-destination and before signal::Download::received-data to notify that destination file has been created successfully at destination.

destination

the destination URI

This signal is emitted after response is received to decide a destination URI for the download. If this signal is not handled the file will be downloaded to G_USER_DIRECTORY_DOWNLOAD directory using suggested_filename.

suggested_filename

the filename suggested for the download

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

This signal is emitted when an error occurs during the download operation. The given error, of the domain WEBKIT_DOWNLOAD_ERROR, contains further details of the failure. If the download is cancelled with cancel(), this signal is emitted with error DownloadError::CancelledByUser. The download operation finishes after an error and signal::Download::finished signal is emitted after this one.

error

the glib::Error that was triggered

This signal is emitted when download finishes successfully or due to an error. In case of errors signal::Download::failed signal is emitted before this one.

This signal is emitted after response is received, every time new data has been written to the destination. It’s useful to know the progress of the download operation.

data_length

the length of data received in bytes

Available on crate feature v2_6 only.

Implementors