rustenium_cdp_definitions/browser_protocol/browser/
events.rs1use serde::{Deserialize, Serialize};
2#[doc = "Fired when page is about to start a download.\n[downloadWillBegin](https://chromedevtools.github.io/devtools-protocol/tot/Browser/#event-downloadWillBegin)"]
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct DownloadWillBeginParams {
5 #[doc = "Id of the frame that caused the download to begin."]
6 #[serde(rename = "frameId")]
7 pub frame_id: crate::browser_protocol::page::types::FrameId,
8 #[doc = "Global unique identifier of the download."]
9 #[serde(rename = "guid")]
10 pub guid: String,
11 #[doc = "URL of the resource being downloaded."]
12 #[serde(rename = "url")]
13 pub url: String,
14 #[doc = "Suggested file name of the resource (the actual name of the file saved on disk may differ)."]
15 #[serde(rename = "suggestedFilename")]
16 pub suggested_filename: String,
17}
18#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
19pub enum DownloadWillBeginMethod {
20 #[serde(rename = "Browser.downloadWillBegin")]
21 DownloadWillBegin,
22}
23#[doc = "Fired when page is about to start a download.\n[downloadWillBegin](https://chromedevtools.github.io/devtools-protocol/tot/Browser/#event-downloadWillBegin)"]
24#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
25pub struct DownloadWillBegin {
26 pub method: DownloadWillBeginMethod,
27 pub params: DownloadWillBeginParams,
28}
29impl DownloadWillBegin {
30 pub const IDENTIFIER: &'static str = "Browser.downloadWillBegin";
31 pub fn identifier(&self) -> &'static str {
32 Self::IDENTIFIER
33 }
34}
35#[doc = "Fired when download makes progress. Last call has |done| == true.\n[downloadProgress](https://chromedevtools.github.io/devtools-protocol/tot/Browser/#event-downloadProgress)"]
36#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
37pub struct DownloadProgressParams {
38 #[doc = "Global unique identifier of the download."]
39 #[serde(rename = "guid")]
40 pub guid: String,
41 #[doc = "Total expected bytes to download."]
42 #[serde(rename = "totalBytes")]
43 pub total_bytes: f64,
44 #[doc = "Total bytes received."]
45 #[serde(rename = "receivedBytes")]
46 pub received_bytes: f64,
47 #[doc = "Download status."]
48 #[serde(rename = "state")]
49 pub state: DownloadProgressState,
50 #[doc = "If download is \"completed\", provides the path of the downloaded file.\nDepending on the platform, it is not guaranteed to be set, nor the file\nis guaranteed to exist."]
51 #[serde(rename = "filePath")]
52 #[serde(skip_serializing_if = "Option::is_none")]
53 #[serde(default)]
54 pub file_path: Option<String>,
55}
56#[doc = "Download status."]
57#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
58pub enum DownloadProgressState {
59 #[serde(rename = "inProgress")]
60 InProgress,
61 #[serde(rename = "completed")]
62 Completed,
63 #[serde(rename = "canceled")]
64 Canceled,
65}
66#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
67pub enum DownloadProgressMethod {
68 #[serde(rename = "Browser.downloadProgress")]
69 DownloadProgress,
70}
71#[doc = "Fired when download makes progress. Last call has |done| == true.\n[downloadProgress](https://chromedevtools.github.io/devtools-protocol/tot/Browser/#event-downloadProgress)"]
72#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
73pub struct DownloadProgress {
74 pub method: DownloadProgressMethod,
75 pub params: DownloadProgressParams,
76}
77impl DownloadProgress {
78 pub const IDENTIFIER: &'static str = "Browser.downloadProgress";
79 pub fn identifier(&self) -> &'static str {
80 Self::IDENTIFIER
81 }
82}
83group_enum ! (BrowserEvents { DownloadWillBegin (DownloadWillBegin) , DownloadProgress (DownloadProgress) } + identifiable);