playwright_core/protocol/
response.rs1use crate::channel_owner::{ChannelOwner, ChannelOwnerImpl, ParentOrConnection};
8use crate::error::Result;
9use serde_json::Value;
10use std::any::Any;
11use std::sync::Arc;
12
13#[derive(Clone)]
20pub struct ResponseObject {
21 base: ChannelOwnerImpl,
22}
23
24impl ResponseObject {
25 pub fn new(
30 parent: Arc<dyn ChannelOwner>,
31 type_name: String,
32 guid: Arc<str>,
33 initializer: Value,
34 ) -> Result<Self> {
35 let base = ChannelOwnerImpl::new(
36 ParentOrConnection::Parent(parent),
37 type_name,
38 guid,
39 initializer,
40 );
41
42 Ok(Self { base })
43 }
44}
45
46impl ChannelOwner for ResponseObject {
47 fn guid(&self) -> &str {
48 self.base.guid()
49 }
50
51 fn type_name(&self) -> &str {
52 self.base.type_name()
53 }
54
55 fn parent(&self) -> Option<Arc<dyn ChannelOwner>> {
56 self.base.parent()
57 }
58
59 fn connection(&self) -> Arc<dyn crate::connection::ConnectionLike> {
60 self.base.connection()
61 }
62
63 fn initializer(&self) -> &Value {
64 self.base.initializer()
65 }
66
67 fn channel(&self) -> &crate::channel::Channel {
68 self.base.channel()
69 }
70
71 fn dispose(&self, reason: crate::channel_owner::DisposeReason) {
72 self.base.dispose(reason)
73 }
74
75 fn adopt(&self, child: Arc<dyn ChannelOwner>) {
76 self.base.adopt(child)
77 }
78
79 fn add_child(&self, guid: Arc<str>, child: Arc<dyn ChannelOwner>) {
80 self.base.add_child(guid, child)
81 }
82
83 fn remove_child(&self, guid: &str) {
84 self.base.remove_child(guid)
85 }
86
87 fn on_event(&self, _method: &str, _params: Value) {
88 }
90
91 fn was_collected(&self) -> bool {
92 self.base.was_collected()
93 }
94
95 fn as_any(&self) -> &dyn Any {
96 self
97 }
98}
99
100impl std::fmt::Debug for ResponseObject {
101 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
102 f.debug_struct("ResponseObject")
103 .field("guid", &self.guid())
104 .finish()
105 }
106}