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    frameId: crate::page::FrameId<'a>,
17}
18
19impl<'a> CrashReportContextEntry<'a> {
20    pub fn builder(key: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>, frameId: crate::page::FrameId<'a>) -> CrashReportContextEntryBuilder<'a> {
21        CrashReportContextEntryBuilder {
22            key: key.into(),
23            value: value.into(),
24            frameId: frameId,
25        }
26    }
27    pub fn key(&self) -> &str { self.key.as_ref() }
28    pub fn value(&self) -> &str { self.value.as_ref() }
29    pub fn frameId(&self) -> &crate::page::FrameId<'a> { &self.frameId }
30}
31
32
33pub struct CrashReportContextEntryBuilder<'a> {
34    key: Cow<'a, str>,
35    value: Cow<'a, str>,
36    frameId: crate::page::FrameId<'a>,
37}
38
39impl<'a> CrashReportContextEntryBuilder<'a> {
40    pub fn build(self) -> CrashReportContextEntry<'a> {
41        CrashReportContextEntry {
42            key: self.key,
43            value: self.value,
44            frameId: self.frameId,
45        }
46    }
47}
48
49/// Returns all entries in the CrashReportContext across all frames in the page.
50
51#[derive(Debug, Clone, Serialize, Deserialize, Default)]
52#[serde(rename_all = "camelCase")]
53pub struct GetEntriesReturns<'a> {
54    entries: Vec<CrashReportContextEntry<'a>>,
55}
56
57impl<'a> GetEntriesReturns<'a> {
58    pub fn builder(entries: Vec<CrashReportContextEntry<'a>>) -> GetEntriesReturnsBuilder<'a> {
59        GetEntriesReturnsBuilder {
60            entries: entries,
61        }
62    }
63    pub fn entries(&self) -> &[CrashReportContextEntry<'a>] { &self.entries }
64}
65
66
67pub struct GetEntriesReturnsBuilder<'a> {
68    entries: Vec<CrashReportContextEntry<'a>>,
69}
70
71impl<'a> GetEntriesReturnsBuilder<'a> {
72    pub fn build(self) -> GetEntriesReturns<'a> {
73        GetEntriesReturns {
74            entries: self.entries,
75        }
76    }
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize, Default)]
80pub struct GetEntriesParams {}
81
82impl GetEntriesParams { pub const METHOD: &'static str = "CrashReportContext.getEntries"; }
83
84impl<'a> crate::CdpCommand<'a> for GetEntriesParams {
85    const METHOD: &'static str = "CrashReportContext.getEntries";
86    type Response = GetEntriesReturns<'a>;
87}