viewpoint_cdp/protocol/storage/
mod.rs1use serde::{Deserialize, Serialize};
6
7pub use super::network_cookies::{Cookie, CookieParam, CookieSameSite};
9
10#[derive(Debug, Clone, Serialize)]
12#[serde(rename_all = "camelCase")]
13pub struct SetCookiesParams {
14 pub cookies: Vec<CookieParam>,
16 #[serde(skip_serializing_if = "Option::is_none")]
18 pub browser_context_id: Option<String>,
19}
20
21impl SetCookiesParams {
22 pub fn new(cookies: Vec<CookieParam>) -> Self {
24 Self {
25 cookies,
26 browser_context_id: None,
27 }
28 }
29
30 #[must_use]
32 pub fn browser_context_id(mut self, id: impl Into<String>) -> Self {
33 self.browser_context_id = Some(id.into());
34 self
35 }
36}
37
38#[derive(Debug, Clone, Serialize, Default)]
40#[serde(rename_all = "camelCase")]
41pub struct GetCookiesParams {
42 #[serde(skip_serializing_if = "Option::is_none")]
44 pub browser_context_id: Option<String>,
45}
46
47impl GetCookiesParams {
48 pub fn new() -> Self {
50 Self::default()
51 }
52
53 #[must_use]
55 pub fn browser_context_id(mut self, id: impl Into<String>) -> Self {
56 self.browser_context_id = Some(id.into());
57 self
58 }
59}
60
61#[derive(Debug, Clone, Deserialize)]
63#[serde(rename_all = "camelCase")]
64pub struct GetCookiesResult {
65 pub cookies: Vec<Cookie>,
67}
68
69#[derive(Debug, Clone, Serialize)]
71#[serde(rename_all = "camelCase")]
72pub struct DeleteCookiesParams {
73 pub name: String,
75 #[serde(skip_serializing_if = "Option::is_none")]
77 pub url: Option<String>,
78 #[serde(skip_serializing_if = "Option::is_none")]
80 pub domain: Option<String>,
81 #[serde(skip_serializing_if = "Option::is_none")]
83 pub path: Option<String>,
84 #[serde(skip_serializing_if = "Option::is_none")]
86 pub partition_key: Option<String>,
87 #[serde(skip_serializing_if = "Option::is_none")]
89 pub browser_context_id: Option<String>,
90}
91
92impl DeleteCookiesParams {
93 pub fn new(name: impl Into<String>) -> Self {
95 Self {
96 name: name.into(),
97 url: None,
98 domain: None,
99 path: None,
100 partition_key: None,
101 browser_context_id: None,
102 }
103 }
104
105 #[must_use]
107 pub fn url(mut self, url: impl Into<String>) -> Self {
108 self.url = Some(url.into());
109 self
110 }
111
112 #[must_use]
114 pub fn domain(mut self, domain: impl Into<String>) -> Self {
115 self.domain = Some(domain.into());
116 self
117 }
118
119 #[must_use]
121 pub fn path(mut self, path: impl Into<String>) -> Self {
122 self.path = Some(path.into());
123 self
124 }
125
126 #[must_use]
128 pub fn browser_context_id(mut self, id: impl Into<String>) -> Self {
129 self.browser_context_id = Some(id.into());
130 self
131 }
132}
133
134#[derive(Debug, Clone, Serialize, Default)]
136#[serde(rename_all = "camelCase")]
137pub struct ClearCookiesParams {
138 #[serde(skip_serializing_if = "Option::is_none")]
140 pub browser_context_id: Option<String>,
141}
142
143impl ClearCookiesParams {
144 pub fn new() -> Self {
146 Self::default()
147 }
148
149 #[must_use]
151 pub fn browser_context_id(mut self, id: impl Into<String>) -> Self {
152 self.browser_context_id = Some(id.into());
153 self
154 }
155}