webkit_web_process_extension6/auto/
uri_request.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from webkit-gir-files
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "WebKitURIRequest")]
16    pub struct URIRequest(Object<ffi::WebKitURIRequest, ffi::WebKitURIRequestClass>);
17
18    match fn {
19        type_ => || ffi::webkit_uri_request_get_type(),
20    }
21}
22
23impl URIRequest {
24    #[doc(alias = "webkit_uri_request_new")]
25    pub fn new(uri: &str) -> URIRequest {
26        assert_initialized_main_thread!();
27        unsafe { from_glib_full(ffi::webkit_uri_request_new(uri.to_glib_none().0)) }
28    }
29
30    #[doc(alias = "webkit_uri_request_get_http_headers")]
31    #[doc(alias = "get_http_headers")]
32    pub fn http_headers(&self) -> Option<soup::MessageHeaders> {
33        unsafe {
34            from_glib_none(ffi::webkit_uri_request_get_http_headers(
35                self.to_glib_none().0,
36            ))
37        }
38    }
39
40    #[doc(alias = "webkit_uri_request_get_http_method")]
41    #[doc(alias = "get_http_method")]
42    pub fn http_method(&self) -> Option<glib::GString> {
43        unsafe {
44            from_glib_none(ffi::webkit_uri_request_get_http_method(
45                self.to_glib_none().0,
46            ))
47        }
48    }
49
50    #[doc(alias = "webkit_uri_request_get_uri")]
51    #[doc(alias = "get_uri")]
52    pub fn uri(&self) -> Option<glib::GString> {
53        unsafe { from_glib_none(ffi::webkit_uri_request_get_uri(self.to_glib_none().0)) }
54    }
55
56    #[doc(alias = "webkit_uri_request_set_uri")]
57    #[doc(alias = "uri")]
58    pub fn set_uri(&self, uri: &str) {
59        unsafe {
60            ffi::webkit_uri_request_set_uri(self.to_glib_none().0, uri.to_glib_none().0);
61        }
62    }
63
64    #[doc(alias = "uri")]
65    pub fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
66        unsafe extern "C" fn notify_uri_trampoline<F: Fn(&URIRequest) + 'static>(
67            this: *mut ffi::WebKitURIRequest,
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::uri".as_ptr() as *const _,
79                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
80                    notify_uri_trampoline::<F> as *const (),
81                )),
82                Box_::into_raw(f),
83            )
84        }
85    }
86}