webkit_web_process_extension6/auto/
uri_response.rs1use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "WebKitURIResponse")]
16 pub struct URIResponse(Object<ffi::WebKitURIResponse, ffi::WebKitURIResponseClass>);
17
18 match fn {
19 type_ => || ffi::webkit_uri_response_get_type(),
20 }
21}
22
23impl URIResponse {
24 #[doc(alias = "webkit_uri_response_get_content_length")]
25 #[doc(alias = "get_content_length")]
26 #[doc(alias = "content-length")]
27 pub fn content_length(&self) -> u64 {
28 unsafe { ffi::webkit_uri_response_get_content_length(self.to_glib_none().0) }
29 }
30
31 #[doc(alias = "webkit_uri_response_get_http_headers")]
32 #[doc(alias = "get_http_headers")]
33 #[doc(alias = "http-headers")]
34 pub fn http_headers(&self) -> Option<soup::MessageHeaders> {
35 unsafe {
36 from_glib_none(ffi::webkit_uri_response_get_http_headers(
37 self.to_glib_none().0,
38 ))
39 }
40 }
41
42 #[doc(alias = "webkit_uri_response_get_mime_type")]
43 #[doc(alias = "get_mime_type")]
44 #[doc(alias = "mime-type")]
45 pub fn mime_type(&self) -> Option<glib::GString> {
46 unsafe {
47 from_glib_none(ffi::webkit_uri_response_get_mime_type(
48 self.to_glib_none().0,
49 ))
50 }
51 }
52
53 #[doc(alias = "webkit_uri_response_get_status_code")]
54 #[doc(alias = "get_status_code")]
55 #[doc(alias = "status-code")]
56 pub fn status_code(&self) -> u32 {
57 unsafe { ffi::webkit_uri_response_get_status_code(self.to_glib_none().0) }
58 }
59
60 #[doc(alias = "webkit_uri_response_get_suggested_filename")]
61 #[doc(alias = "get_suggested_filename")]
62 #[doc(alias = "suggested-filename")]
63 pub fn suggested_filename(&self) -> Option<glib::GString> {
64 unsafe {
65 from_glib_none(ffi::webkit_uri_response_get_suggested_filename(
66 self.to_glib_none().0,
67 ))
68 }
69 }
70
71 #[doc(alias = "webkit_uri_response_get_uri")]
72 #[doc(alias = "get_uri")]
73 pub fn uri(&self) -> Option<glib::GString> {
74 unsafe { from_glib_none(ffi::webkit_uri_response_get_uri(self.to_glib_none().0)) }
75 }
76
77 #[doc(alias = "content-length")]
78 pub fn connect_content_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
79 unsafe extern "C" fn notify_content_length_trampoline<F: Fn(&URIResponse) + 'static>(
80 this: *mut ffi::WebKitURIResponse,
81 _param_spec: glib::ffi::gpointer,
82 f: glib::ffi::gpointer,
83 ) {
84 unsafe {
85 let f: &F = &*(f as *const F);
86 f(&from_glib_borrow(this))
87 }
88 }
89 unsafe {
90 let f: Box_<F> = Box_::new(f);
91 connect_raw(
92 self.as_ptr() as *mut _,
93 c"notify::content-length".as_ptr(),
94 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
95 notify_content_length_trampoline::<F> as *const (),
96 )),
97 Box_::into_raw(f),
98 )
99 }
100 }
101
102 #[doc(alias = "http-headers")]
103 pub fn connect_http_headers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
104 unsafe extern "C" fn notify_http_headers_trampoline<F: Fn(&URIResponse) + 'static>(
105 this: *mut ffi::WebKitURIResponse,
106 _param_spec: glib::ffi::gpointer,
107 f: glib::ffi::gpointer,
108 ) {
109 unsafe {
110 let f: &F = &*(f as *const F);
111 f(&from_glib_borrow(this))
112 }
113 }
114 unsafe {
115 let f: Box_<F> = Box_::new(f);
116 connect_raw(
117 self.as_ptr() as *mut _,
118 c"notify::http-headers".as_ptr(),
119 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
120 notify_http_headers_trampoline::<F> as *const (),
121 )),
122 Box_::into_raw(f),
123 )
124 }
125 }
126
127 #[doc(alias = "mime-type")]
128 pub fn connect_mime_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
129 unsafe extern "C" fn notify_mime_type_trampoline<F: Fn(&URIResponse) + 'static>(
130 this: *mut ffi::WebKitURIResponse,
131 _param_spec: glib::ffi::gpointer,
132 f: glib::ffi::gpointer,
133 ) {
134 unsafe {
135 let f: &F = &*(f as *const F);
136 f(&from_glib_borrow(this))
137 }
138 }
139 unsafe {
140 let f: Box_<F> = Box_::new(f);
141 connect_raw(
142 self.as_ptr() as *mut _,
143 c"notify::mime-type".as_ptr(),
144 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
145 notify_mime_type_trampoline::<F> as *const (),
146 )),
147 Box_::into_raw(f),
148 )
149 }
150 }
151
152 #[doc(alias = "status-code")]
153 pub fn connect_status_code_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
154 unsafe extern "C" fn notify_status_code_trampoline<F: Fn(&URIResponse) + 'static>(
155 this: *mut ffi::WebKitURIResponse,
156 _param_spec: glib::ffi::gpointer,
157 f: glib::ffi::gpointer,
158 ) {
159 unsafe {
160 let f: &F = &*(f as *const F);
161 f(&from_glib_borrow(this))
162 }
163 }
164 unsafe {
165 let f: Box_<F> = Box_::new(f);
166 connect_raw(
167 self.as_ptr() as *mut _,
168 c"notify::status-code".as_ptr(),
169 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
170 notify_status_code_trampoline::<F> as *const (),
171 )),
172 Box_::into_raw(f),
173 )
174 }
175 }
176
177 #[doc(alias = "suggested-filename")]
178 pub fn connect_suggested_filename_notify<F: Fn(&Self) + 'static>(
179 &self,
180 f: F,
181 ) -> SignalHandlerId {
182 unsafe extern "C" fn notify_suggested_filename_trampoline<F: Fn(&URIResponse) + 'static>(
183 this: *mut ffi::WebKitURIResponse,
184 _param_spec: glib::ffi::gpointer,
185 f: glib::ffi::gpointer,
186 ) {
187 unsafe {
188 let f: &F = &*(f as *const F);
189 f(&from_glib_borrow(this))
190 }
191 }
192 unsafe {
193 let f: Box_<F> = Box_::new(f);
194 connect_raw(
195 self.as_ptr() as *mut _,
196 c"notify::suggested-filename".as_ptr(),
197 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
198 notify_suggested_filename_trampoline::<F> as *const (),
199 )),
200 Box_::into_raw(f),
201 )
202 }
203 }
204
205 #[doc(alias = "uri")]
206 pub fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
207 unsafe extern "C" fn notify_uri_trampoline<F: Fn(&URIResponse) + 'static>(
208 this: *mut ffi::WebKitURIResponse,
209 _param_spec: glib::ffi::gpointer,
210 f: glib::ffi::gpointer,
211 ) {
212 unsafe {
213 let f: &F = &*(f as *const F);
214 f(&from_glib_borrow(this))
215 }
216 }
217 unsafe {
218 let f: Box_<F> = Box_::new(f);
219 connect_raw(
220 self.as_ptr() as *mut _,
221 c"notify::uri".as_ptr(),
222 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
223 notify_uri_trampoline::<F> as *const (),
224 )),
225 Box_::into_raw(f),
226 )
227 }
228 }
229}