Skip to main content

browser_protocol/crashreportcontext/
mod.rs

1//! This domain exposes the current state of the CrashReportContext API.
2
3
4use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8/// Key-value pair in CrashReportContext.
9
10#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct CrashReportContextEntry<'a> {
13    key: Cow<'a, str>,
14    value: Cow<'a, str>,
15    /// The ID of the frame where the key-value pair was set.
16    #[serde(rename = "frameId")]
17    frame_id: crate::page::FrameId<'a>,
18}
19
20impl<'a> CrashReportContextEntry<'a> {
21    /// Creates a builder for this type with the required parameters:
22    /// * `key`: 
23    /// * `value`: 
24    /// * `frame_id`: The ID of the frame where the key-value pair was set.
25    pub fn builder(key: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>, frame_id: crate::page::FrameId<'a>) -> CrashReportContextEntryBuilder<'a> {
26        CrashReportContextEntryBuilder {
27            key: key.into(),
28            value: value.into(),
29            frame_id: frame_id,
30        }
31    }
32    pub fn key(&self) -> &str { self.key.as_ref() }
33    pub fn value(&self) -> &str { self.value.as_ref() }
34    /// The ID of the frame where the key-value pair was set.
35    pub fn frame_id(&self) -> &crate::page::FrameId<'a> { &self.frame_id }
36}
37
38
39pub struct CrashReportContextEntryBuilder<'a> {
40    key: Cow<'a, str>,
41    value: Cow<'a, str>,
42    frame_id: crate::page::FrameId<'a>,
43}
44
45impl<'a> CrashReportContextEntryBuilder<'a> {
46    pub fn build(self) -> CrashReportContextEntry<'a> {
47        CrashReportContextEntry {
48            key: self.key,
49            value: self.value,
50            frame_id: self.frame_id,
51        }
52    }
53}
54
55/// Returns all entries in the CrashReportContext across all frames in the page.
56
57#[derive(Debug, Clone, Serialize, Deserialize, Default)]
58#[serde(rename_all = "camelCase")]
59pub struct GetEntriesReturns<'a> {
60    entries: Vec<CrashReportContextEntry<'a>>,
61}
62
63impl<'a> GetEntriesReturns<'a> {
64    /// Creates a builder for this type with the required parameters:
65    /// * `entries`: 
66    pub fn builder(entries: Vec<CrashReportContextEntry<'a>>) -> GetEntriesReturnsBuilder<'a> {
67        GetEntriesReturnsBuilder {
68            entries: entries,
69        }
70    }
71    pub fn entries(&self) -> &[CrashReportContextEntry<'a>] { &self.entries }
72}
73
74
75pub struct GetEntriesReturnsBuilder<'a> {
76    entries: Vec<CrashReportContextEntry<'a>>,
77}
78
79impl<'a> GetEntriesReturnsBuilder<'a> {
80    pub fn build(self) -> GetEntriesReturns<'a> {
81        GetEntriesReturns {
82            entries: self.entries,
83        }
84    }
85}
86
87#[derive(Debug, Clone, Serialize, Deserialize, Default)]
88pub struct GetEntriesParams {}
89
90impl GetEntriesParams { pub const METHOD: &'static str = "CrashReportContext.getEntries"; }
91
92impl<'a> crate::CdpCommand<'a> for GetEntriesParams {
93    const METHOD: &'static str = "CrashReportContext.getEntries";
94    type Response = GetEntriesReturns<'a>;
95}