viewpoint_cdp/protocol/page/
types.rs

1//! Page domain core types.
2
3use serde::{Deserialize, Serialize};
4
5/// Frame information.
6#[derive(Debug, Clone, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct Frame {
9    /// Frame unique identifier.
10    pub id: String,
11    /// Parent frame identifier.
12    pub parent_id: Option<String>,
13    /// Identifier of the loader associated with this frame.
14    pub loader_id: String,
15    /// Frame's name as specified in the tag.
16    pub name: Option<String>,
17    /// Frame document's URL.
18    pub url: String,
19    /// Frame document's security origin.
20    pub security_origin: Option<String>,
21    /// Frame document's mimeType.
22    pub mime_type: Option<String>,
23}
24
25/// Frame tree structure.
26#[derive(Debug, Clone, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct FrameTree {
29    /// Frame information.
30    pub frame: Frame,
31    /// Child frames.
32    pub child_frames: Option<Vec<FrameTree>>,
33}
34
35/// Image format for screenshots.
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Default)]
37#[serde(rename_all = "lowercase")]
38pub enum ScreenshotFormat {
39    /// PNG format (default).
40    #[default]
41    Png,
42    /// JPEG format.
43    Jpeg,
44    /// WebP format.
45    Webp,
46}
47
48/// Viewport for capturing a screenshot.
49#[derive(Debug, Clone, Serialize)]
50#[serde(rename_all = "camelCase")]
51pub struct Viewport {
52    /// X offset in device independent pixels.
53    pub x: f64,
54    /// Y offset in device independent pixels.
55    pub y: f64,
56    /// Rectangle width in device independent pixels.
57    pub width: f64,
58    /// Rectangle height in device independent pixels.
59    pub height: f64,
60    /// Page scale factor.
61    pub scale: f64,
62}
63
64/// Navigation history entry.
65#[derive(Debug, Clone, Deserialize)]
66#[serde(rename_all = "camelCase")]
67pub struct NavigationEntry {
68    /// Unique id of the navigation history entry.
69    pub id: i32,
70    /// URL of the navigation history entry.
71    pub url: String,
72    /// URL that the user typed in the URL bar.
73    #[serde(default)]
74    pub user_typed_url: String,
75    /// Title of the navigation history entry.
76    pub title: String,
77    /// Transition type.
78    #[serde(default)]
79    pub transition_type: String,
80}
81
82/// Reason for frame being detached.
83#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
84#[serde(rename_all = "camelCase")]
85pub enum FrameDetachedReason {
86    /// Frame was removed from the DOM.
87    Remove,
88    /// Frame was swapped (e.g., for out-of-process iframe).
89    Swap,
90}
91
92/// File chooser mode.
93#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
94#[serde(rename_all = "camelCase")]
95pub enum FileChooserMode {
96    /// Select a single file.
97    SelectSingle,
98    /// Select multiple files.
99    SelectMultiple,
100}