soup/auto/
server_message.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi, HTTPVersion, MemoryUse, MessageBody, MessageHeaders};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    #[doc(alias = "SoupServerMessage")]
17    pub struct ServerMessage(Object<ffi::SoupServerMessage, ffi::SoupServerMessageClass>);
18
19    match fn {
20        type_ => || ffi::soup_server_message_get_type(),
21    }
22}
23
24impl ServerMessage {
25    #[doc(alias = "soup_server_message_get_http_version")]
26    #[doc(alias = "get_http_version")]
27    pub fn http_version(&self) -> HTTPVersion {
28        unsafe {
29            from_glib(ffi::soup_server_message_get_http_version(
30                self.to_glib_none().0,
31            ))
32        }
33    }
34
35    #[doc(alias = "soup_server_message_get_local_address")]
36    #[doc(alias = "get_local_address")]
37    pub fn local_address(&self) -> Option<gio::SocketAddress> {
38        unsafe {
39            from_glib_none(ffi::soup_server_message_get_local_address(
40                self.to_glib_none().0,
41            ))
42        }
43    }
44
45    #[doc(alias = "soup_server_message_get_method")]
46    #[doc(alias = "get_method")]
47    pub fn method(&self) -> Option<glib::GString> {
48        unsafe { from_glib_none(ffi::soup_server_message_get_method(self.to_glib_none().0)) }
49    }
50
51    #[doc(alias = "soup_server_message_get_reason_phrase")]
52    #[doc(alias = "get_reason_phrase")]
53    pub fn reason_phrase(&self) -> Option<glib::GString> {
54        unsafe {
55            from_glib_none(ffi::soup_server_message_get_reason_phrase(
56                self.to_glib_none().0,
57            ))
58        }
59    }
60
61    #[doc(alias = "soup_server_message_get_remote_address")]
62    #[doc(alias = "get_remote_address")]
63    pub fn remote_address(&self) -> Option<gio::SocketAddress> {
64        unsafe {
65            from_glib_none(ffi::soup_server_message_get_remote_address(
66                self.to_glib_none().0,
67            ))
68        }
69    }
70
71    #[doc(alias = "soup_server_message_get_remote_host")]
72    #[doc(alias = "get_remote_host")]
73    pub fn remote_host(&self) -> Option<glib::GString> {
74        unsafe {
75            from_glib_none(ffi::soup_server_message_get_remote_host(
76                self.to_glib_none().0,
77            ))
78        }
79    }
80
81    #[doc(alias = "soup_server_message_get_request_body")]
82    #[doc(alias = "get_request_body")]
83    pub fn request_body(&self) -> Option<MessageBody> {
84        unsafe {
85            from_glib_none(ffi::soup_server_message_get_request_body(
86                self.to_glib_none().0,
87            ))
88        }
89    }
90
91    #[doc(alias = "soup_server_message_get_request_headers")]
92    #[doc(alias = "get_request_headers")]
93    pub fn request_headers(&self) -> Option<MessageHeaders> {
94        unsafe {
95            from_glib_none(ffi::soup_server_message_get_request_headers(
96                self.to_glib_none().0,
97            ))
98        }
99    }
100
101    #[doc(alias = "soup_server_message_get_response_body")]
102    #[doc(alias = "get_response_body")]
103    pub fn response_body(&self) -> Option<MessageBody> {
104        unsafe {
105            from_glib_none(ffi::soup_server_message_get_response_body(
106                self.to_glib_none().0,
107            ))
108        }
109    }
110
111    #[doc(alias = "soup_server_message_get_response_headers")]
112    #[doc(alias = "get_response_headers")]
113    pub fn response_headers(&self) -> Option<MessageHeaders> {
114        unsafe {
115            from_glib_none(ffi::soup_server_message_get_response_headers(
116                self.to_glib_none().0,
117            ))
118        }
119    }
120
121    #[doc(alias = "soup_server_message_get_socket")]
122    #[doc(alias = "get_socket")]
123    pub fn socket(&self) -> Option<gio::Socket> {
124        unsafe { from_glib_none(ffi::soup_server_message_get_socket(self.to_glib_none().0)) }
125    }
126
127    #[doc(alias = "soup_server_message_get_status")]
128    #[doc(alias = "get_status")]
129    pub fn status(&self) -> u32 {
130        unsafe { ffi::soup_server_message_get_status(self.to_glib_none().0) }
131    }
132
133    #[cfg(feature = "v3_2")]
134    #[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
135    #[doc(alias = "soup_server_message_get_tls_peer_certificate")]
136    #[doc(alias = "get_tls_peer_certificate")]
137    #[doc(alias = "tls-peer-certificate")]
138    pub fn tls_peer_certificate(&self) -> Option<gio::TlsCertificate> {
139        unsafe {
140            from_glib_none(ffi::soup_server_message_get_tls_peer_certificate(
141                self.to_glib_none().0,
142            ))
143        }
144    }
145
146    #[cfg(feature = "v3_2")]
147    #[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
148    #[doc(alias = "soup_server_message_get_tls_peer_certificate_errors")]
149    #[doc(alias = "get_tls_peer_certificate_errors")]
150    #[doc(alias = "tls-peer-certificate-errors")]
151    pub fn tls_peer_certificate_errors(&self) -> gio::TlsCertificateFlags {
152        unsafe {
153            from_glib(ffi::soup_server_message_get_tls_peer_certificate_errors(
154                self.to_glib_none().0,
155            ))
156        }
157    }
158
159    #[doc(alias = "soup_server_message_get_uri")]
160    #[doc(alias = "get_uri")]
161    pub fn uri(&self) -> Option<glib::Uri> {
162        unsafe { from_glib_none(ffi::soup_server_message_get_uri(self.to_glib_none().0)) }
163    }
164
165    #[doc(alias = "soup_server_message_is_options_ping")]
166    pub fn is_options_ping(&self) -> bool {
167        unsafe {
168            from_glib(ffi::soup_server_message_is_options_ping(
169                self.to_glib_none().0,
170            ))
171        }
172    }
173
174    #[cfg(feature = "v3_2")]
175    #[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
176    #[doc(alias = "soup_server_message_pause")]
177    pub fn pause(&self) {
178        unsafe {
179            ffi::soup_server_message_pause(self.to_glib_none().0);
180        }
181    }
182
183    #[doc(alias = "soup_server_message_set_http_version")]
184    pub fn set_http_version(&self, version: HTTPVersion) {
185        unsafe {
186            ffi::soup_server_message_set_http_version(self.to_glib_none().0, version.into_glib());
187        }
188    }
189
190    #[doc(alias = "soup_server_message_set_redirect")]
191    pub fn set_redirect(&self, status_code: u32, redirect_uri: &str) {
192        unsafe {
193            ffi::soup_server_message_set_redirect(
194                self.to_glib_none().0,
195                status_code,
196                redirect_uri.to_glib_none().0,
197            );
198        }
199    }
200
201    #[doc(alias = "soup_server_message_set_response")]
202    pub fn set_response(&self, content_type: Option<&str>, resp_use: MemoryUse, resp_body: &[u8]) {
203        let resp_length = resp_body.len() as _;
204        unsafe {
205            ffi::soup_server_message_set_response(
206                self.to_glib_none().0,
207                content_type.to_glib_none().0,
208                resp_use.into_glib(),
209                resp_body.to_glib_none().0,
210                resp_length,
211            );
212        }
213    }
214
215    #[doc(alias = "soup_server_message_set_status")]
216    pub fn set_status(&self, status_code: u32, reason_phrase: Option<&str>) {
217        unsafe {
218            ffi::soup_server_message_set_status(
219                self.to_glib_none().0,
220                status_code,
221                reason_phrase.to_glib_none().0,
222            );
223        }
224    }
225
226    #[doc(alias = "soup_server_message_steal_connection")]
227    pub fn steal_connection(&self) -> Option<gio::IOStream> {
228        unsafe {
229            from_glib_full(ffi::soup_server_message_steal_connection(
230                self.to_glib_none().0,
231            ))
232        }
233    }
234
235    #[cfg(feature = "v3_2")]
236    #[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
237    #[doc(alias = "soup_server_message_unpause")]
238    pub fn unpause(&self) {
239        unsafe {
240            ffi::soup_server_message_unpause(self.to_glib_none().0);
241        }
242    }
243
244    #[doc(alias = "accept-certificate")]
245    pub fn connect_accept_certificate<
246        F: Fn(&Self, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
247    >(
248        &self,
249        f: F,
250    ) -> SignalHandlerId {
251        unsafe extern "C" fn accept_certificate_trampoline<
252            F: Fn(&ServerMessage, &gio::TlsCertificate, gio::TlsCertificateFlags) -> bool + 'static,
253        >(
254            this: *mut ffi::SoupServerMessage,
255            tls_peer_certificate: *mut gio::ffi::GTlsCertificate,
256            tls_peer_errors: gio::ffi::GTlsCertificateFlags,
257            f: glib::ffi::gpointer,
258        ) -> glib::ffi::gboolean {
259            let f: &F = &*(f as *const F);
260            f(
261                &from_glib_borrow(this),
262                &from_glib_borrow(tls_peer_certificate),
263                from_glib(tls_peer_errors),
264            )
265            .into_glib()
266        }
267        unsafe {
268            let f: Box_<F> = Box_::new(f);
269            connect_raw(
270                self.as_ptr() as *mut _,
271                c"accept-certificate".as_ptr() as *const _,
272                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
273                    accept_certificate_trampoline::<F> as *const (),
274                )),
275                Box_::into_raw(f),
276            )
277        }
278    }
279
280    #[doc(alias = "connected")]
281    pub fn connect_connected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
282        unsafe extern "C" fn connected_trampoline<F: Fn(&ServerMessage) + 'static>(
283            this: *mut ffi::SoupServerMessage,
284            f: glib::ffi::gpointer,
285        ) {
286            let f: &F = &*(f as *const F);
287            f(&from_glib_borrow(this))
288        }
289        unsafe {
290            let f: Box_<F> = Box_::new(f);
291            connect_raw(
292                self.as_ptr() as *mut _,
293                c"connected".as_ptr() as *const _,
294                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
295                    connected_trampoline::<F> as *const (),
296                )),
297                Box_::into_raw(f),
298            )
299        }
300    }
301
302    #[doc(alias = "disconnected")]
303    pub fn connect_disconnected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
304        unsafe extern "C" fn disconnected_trampoline<F: Fn(&ServerMessage) + 'static>(
305            this: *mut ffi::SoupServerMessage,
306            f: glib::ffi::gpointer,
307        ) {
308            let f: &F = &*(f as *const F);
309            f(&from_glib_borrow(this))
310        }
311        unsafe {
312            let f: Box_<F> = Box_::new(f);
313            connect_raw(
314                self.as_ptr() as *mut _,
315                c"disconnected".as_ptr() as *const _,
316                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
317                    disconnected_trampoline::<F> as *const (),
318                )),
319                Box_::into_raw(f),
320            )
321        }
322    }
323
324    #[doc(alias = "finished")]
325    pub fn connect_finished<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
326        unsafe extern "C" fn finished_trampoline<F: Fn(&ServerMessage) + 'static>(
327            this: *mut ffi::SoupServerMessage,
328            f: glib::ffi::gpointer,
329        ) {
330            let f: &F = &*(f as *const F);
331            f(&from_glib_borrow(this))
332        }
333        unsafe {
334            let f: Box_<F> = Box_::new(f);
335            connect_raw(
336                self.as_ptr() as *mut _,
337                c"finished".as_ptr() as *const _,
338                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
339                    finished_trampoline::<F> as *const (),
340                )),
341                Box_::into_raw(f),
342            )
343        }
344    }
345
346    #[doc(alias = "got-body")]
347    pub fn connect_got_body<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
348        unsafe extern "C" fn got_body_trampoline<F: Fn(&ServerMessage) + 'static>(
349            this: *mut ffi::SoupServerMessage,
350            f: glib::ffi::gpointer,
351        ) {
352            let f: &F = &*(f as *const F);
353            f(&from_glib_borrow(this))
354        }
355        unsafe {
356            let f: Box_<F> = Box_::new(f);
357            connect_raw(
358                self.as_ptr() as *mut _,
359                c"got-body".as_ptr() as *const _,
360                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
361                    got_body_trampoline::<F> as *const (),
362                )),
363                Box_::into_raw(f),
364            )
365        }
366    }
367
368    #[doc(alias = "got-chunk")]
369    pub fn connect_got_chunk<F: Fn(&Self, &glib::Bytes) + 'static>(&self, f: F) -> SignalHandlerId {
370        unsafe extern "C" fn got_chunk_trampoline<F: Fn(&ServerMessage, &glib::Bytes) + 'static>(
371            this: *mut ffi::SoupServerMessage,
372            chunk: *mut glib::ffi::GBytes,
373            f: glib::ffi::gpointer,
374        ) {
375            let f: &F = &*(f as *const F);
376            f(&from_glib_borrow(this), &from_glib_borrow(chunk))
377        }
378        unsafe {
379            let f: Box_<F> = Box_::new(f);
380            connect_raw(
381                self.as_ptr() as *mut _,
382                c"got-chunk".as_ptr() as *const _,
383                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
384                    got_chunk_trampoline::<F> as *const (),
385                )),
386                Box_::into_raw(f),
387            )
388        }
389    }
390
391    #[doc(alias = "got-headers")]
392    pub fn connect_got_headers<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
393        unsafe extern "C" fn got_headers_trampoline<F: Fn(&ServerMessage) + 'static>(
394            this: *mut ffi::SoupServerMessage,
395            f: glib::ffi::gpointer,
396        ) {
397            let f: &F = &*(f as *const F);
398            f(&from_glib_borrow(this))
399        }
400        unsafe {
401            let f: Box_<F> = Box_::new(f);
402            connect_raw(
403                self.as_ptr() as *mut _,
404                c"got-headers".as_ptr() as *const _,
405                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
406                    got_headers_trampoline::<F> as *const (),
407                )),
408                Box_::into_raw(f),
409            )
410        }
411    }
412
413    #[doc(alias = "wrote-body")]
414    pub fn connect_wrote_body<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
415        unsafe extern "C" fn wrote_body_trampoline<F: Fn(&ServerMessage) + 'static>(
416            this: *mut ffi::SoupServerMessage,
417            f: glib::ffi::gpointer,
418        ) {
419            let f: &F = &*(f as *const F);
420            f(&from_glib_borrow(this))
421        }
422        unsafe {
423            let f: Box_<F> = Box_::new(f);
424            connect_raw(
425                self.as_ptr() as *mut _,
426                c"wrote-body".as_ptr() as *const _,
427                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
428                    wrote_body_trampoline::<F> as *const (),
429                )),
430                Box_::into_raw(f),
431            )
432        }
433    }
434
435    #[doc(alias = "wrote-body-data")]
436    pub fn connect_wrote_body_data<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
437        unsafe extern "C" fn wrote_body_data_trampoline<F: Fn(&ServerMessage, u32) + 'static>(
438            this: *mut ffi::SoupServerMessage,
439            chunk_size: std::ffi::c_uint,
440            f: glib::ffi::gpointer,
441        ) {
442            let f: &F = &*(f as *const F);
443            f(&from_glib_borrow(this), chunk_size)
444        }
445        unsafe {
446            let f: Box_<F> = Box_::new(f);
447            connect_raw(
448                self.as_ptr() as *mut _,
449                c"wrote-body-data".as_ptr() as *const _,
450                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
451                    wrote_body_data_trampoline::<F> as *const (),
452                )),
453                Box_::into_raw(f),
454            )
455        }
456    }
457
458    #[doc(alias = "wrote-chunk")]
459    pub fn connect_wrote_chunk<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
460        unsafe extern "C" fn wrote_chunk_trampoline<F: Fn(&ServerMessage) + 'static>(
461            this: *mut ffi::SoupServerMessage,
462            f: glib::ffi::gpointer,
463        ) {
464            let f: &F = &*(f as *const F);
465            f(&from_glib_borrow(this))
466        }
467        unsafe {
468            let f: Box_<F> = Box_::new(f);
469            connect_raw(
470                self.as_ptr() as *mut _,
471                c"wrote-chunk".as_ptr() as *const _,
472                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
473                    wrote_chunk_trampoline::<F> as *const (),
474                )),
475                Box_::into_raw(f),
476            )
477        }
478    }
479
480    #[doc(alias = "wrote-headers")]
481    pub fn connect_wrote_headers<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
482        unsafe extern "C" fn wrote_headers_trampoline<F: Fn(&ServerMessage) + 'static>(
483            this: *mut ffi::SoupServerMessage,
484            f: glib::ffi::gpointer,
485        ) {
486            let f: &F = &*(f as *const F);
487            f(&from_glib_borrow(this))
488        }
489        unsafe {
490            let f: Box_<F> = Box_::new(f);
491            connect_raw(
492                self.as_ptr() as *mut _,
493                c"wrote-headers".as_ptr() as *const _,
494                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
495                    wrote_headers_trampoline::<F> as *const (),
496                )),
497                Box_::into_raw(f),
498            )
499        }
500    }
501
502    #[doc(alias = "wrote-informational")]
503    pub fn connect_wrote_informational<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
504        unsafe extern "C" fn wrote_informational_trampoline<F: Fn(&ServerMessage) + 'static>(
505            this: *mut ffi::SoupServerMessage,
506            f: glib::ffi::gpointer,
507        ) {
508            let f: &F = &*(f as *const F);
509            f(&from_glib_borrow(this))
510        }
511        unsafe {
512            let f: Box_<F> = Box_::new(f);
513            connect_raw(
514                self.as_ptr() as *mut _,
515                c"wrote-informational".as_ptr() as *const _,
516                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
517                    wrote_informational_trampoline::<F> as *const (),
518                )),
519                Box_::into_raw(f),
520            )
521        }
522    }
523
524    #[cfg(feature = "v3_2")]
525    #[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
526    #[doc(alias = "tls-peer-certificate")]
527    pub fn connect_tls_peer_certificate_notify<F: Fn(&Self) + 'static>(
528        &self,
529        f: F,
530    ) -> SignalHandlerId {
531        unsafe extern "C" fn notify_tls_peer_certificate_trampoline<
532            F: Fn(&ServerMessage) + 'static,
533        >(
534            this: *mut ffi::SoupServerMessage,
535            _param_spec: glib::ffi::gpointer,
536            f: glib::ffi::gpointer,
537        ) {
538            let f: &F = &*(f as *const F);
539            f(&from_glib_borrow(this))
540        }
541        unsafe {
542            let f: Box_<F> = Box_::new(f);
543            connect_raw(
544                self.as_ptr() as *mut _,
545                c"notify::tls-peer-certificate".as_ptr() as *const _,
546                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
547                    notify_tls_peer_certificate_trampoline::<F> as *const (),
548                )),
549                Box_::into_raw(f),
550            )
551        }
552    }
553
554    #[cfg(feature = "v3_2")]
555    #[cfg_attr(docsrs, doc(cfg(feature = "v3_2")))]
556    #[doc(alias = "tls-peer-certificate-errors")]
557    pub fn connect_tls_peer_certificate_errors_notify<F: Fn(&Self) + 'static>(
558        &self,
559        f: F,
560    ) -> SignalHandlerId {
561        unsafe extern "C" fn notify_tls_peer_certificate_errors_trampoline<
562            F: Fn(&ServerMessage) + 'static,
563        >(
564            this: *mut ffi::SoupServerMessage,
565            _param_spec: glib::ffi::gpointer,
566            f: glib::ffi::gpointer,
567        ) {
568            let f: &F = &*(f as *const F);
569            f(&from_glib_borrow(this))
570        }
571        unsafe {
572            let f: Box_<F> = Box_::new(f);
573            connect_raw(
574                self.as_ptr() as *mut _,
575                c"notify::tls-peer-certificate-errors".as_ptr() as *const _,
576                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
577                    notify_tls_peer_certificate_errors_trampoline::<F> as *const (),
578                )),
579                Box_::into_raw(f),
580            )
581        }
582    }
583}