webkit6/auto/
response_policy_decision.rs1use crate::{ffi, PolicyDecision, URIRequest, URIResponse};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "WebKitResponsePolicyDecision")]
16 pub struct ResponsePolicyDecision(Object<ffi::WebKitResponsePolicyDecision, ffi::WebKitResponsePolicyDecisionClass>) @extends PolicyDecision;
17
18 match fn {
19 type_ => || ffi::webkit_response_policy_decision_get_type(),
20 }
21}
22
23impl ResponsePolicyDecision {
24 #[doc(alias = "webkit_response_policy_decision_get_request")]
25 #[doc(alias = "get_request")]
26 pub fn request(&self) -> Option<URIRequest> {
27 unsafe {
28 from_glib_none(ffi::webkit_response_policy_decision_get_request(
29 self.to_glib_none().0,
30 ))
31 }
32 }
33
34 #[doc(alias = "webkit_response_policy_decision_get_response")]
35 #[doc(alias = "get_response")]
36 pub fn response(&self) -> Option<URIResponse> {
37 unsafe {
38 from_glib_none(ffi::webkit_response_policy_decision_get_response(
39 self.to_glib_none().0,
40 ))
41 }
42 }
43
44 #[doc(alias = "webkit_response_policy_decision_is_main_frame_main_resource")]
45 pub fn is_main_frame_main_resource(&self) -> bool {
46 unsafe {
47 from_glib(
48 ffi::webkit_response_policy_decision_is_main_frame_main_resource(
49 self.to_glib_none().0,
50 ),
51 )
52 }
53 }
54
55 #[doc(alias = "webkit_response_policy_decision_is_mime_type_supported")]
56 pub fn is_mime_type_supported(&self) -> bool {
57 unsafe {
58 from_glib(ffi::webkit_response_policy_decision_is_mime_type_supported(
59 self.to_glib_none().0,
60 ))
61 }
62 }
63
64 #[doc(alias = "request")]
65 pub fn connect_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
66 unsafe extern "C" fn notify_request_trampoline<F: Fn(&ResponsePolicyDecision) + 'static>(
67 this: *mut ffi::WebKitResponsePolicyDecision,
68 _param_spec: glib::ffi::gpointer,
69 f: glib::ffi::gpointer,
70 ) {
71 let f: &F = &*(f as *const F);
72 f(&from_glib_borrow(this))
73 }
74 unsafe {
75 let f: Box_<F> = Box_::new(f);
76 connect_raw(
77 self.as_ptr() as *mut _,
78 c"notify::request".as_ptr() as *const _,
79 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
80 notify_request_trampoline::<F> as *const (),
81 )),
82 Box_::into_raw(f),
83 )
84 }
85 }
86
87 #[doc(alias = "response")]
88 pub fn connect_response_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
89 unsafe extern "C" fn notify_response_trampoline<
90 F: Fn(&ResponsePolicyDecision) + 'static,
91 >(
92 this: *mut ffi::WebKitResponsePolicyDecision,
93 _param_spec: glib::ffi::gpointer,
94 f: glib::ffi::gpointer,
95 ) {
96 let f: &F = &*(f as *const F);
97 f(&from_glib_borrow(this))
98 }
99 unsafe {
100 let f: Box_<F> = Box_::new(f);
101 connect_raw(
102 self.as_ptr() as *mut _,
103 c"notify::response".as_ptr() as *const _,
104 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
105 notify_response_trampoline::<F> as *const (),
106 )),
107 Box_::into_raw(f),
108 )
109 }
110 }
111}