webkit6 0.6.1

Rust bindings for WebKit 6.0
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT

use crate::ffi;
use glib::{
    prelude::*,
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "WebKitURIResponse")]
    pub struct URIResponse(Object<ffi::WebKitURIResponse, ffi::WebKitURIResponseClass>);

    match fn {
        type_ => || ffi::webkit_uri_response_get_type(),
    }
}

impl URIResponse {
    #[doc(alias = "webkit_uri_response_get_content_length")]
    #[doc(alias = "get_content_length")]
    #[doc(alias = "content-length")]
    pub fn content_length(&self) -> u64 {
        unsafe { ffi::webkit_uri_response_get_content_length(self.to_glib_none().0) }
    }

    #[doc(alias = "webkit_uri_response_get_http_headers")]
    #[doc(alias = "get_http_headers")]
    #[doc(alias = "http-headers")]
    pub fn http_headers(&self) -> Option<soup::MessageHeaders> {
        unsafe {
            from_glib_none(ffi::webkit_uri_response_get_http_headers(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "webkit_uri_response_get_mime_type")]
    #[doc(alias = "get_mime_type")]
    #[doc(alias = "mime-type")]
    pub fn mime_type(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_uri_response_get_mime_type(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "webkit_uri_response_get_status_code")]
    #[doc(alias = "get_status_code")]
    #[doc(alias = "status-code")]
    pub fn status_code(&self) -> u32 {
        unsafe { ffi::webkit_uri_response_get_status_code(self.to_glib_none().0) }
    }

    #[doc(alias = "webkit_uri_response_get_suggested_filename")]
    #[doc(alias = "get_suggested_filename")]
    #[doc(alias = "suggested-filename")]
    pub fn suggested_filename(&self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::webkit_uri_response_get_suggested_filename(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "webkit_uri_response_get_uri")]
    #[doc(alias = "get_uri")]
    pub fn uri(&self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::webkit_uri_response_get_uri(self.to_glib_none().0)) }
    }

    #[doc(alias = "content-length")]
    pub fn connect_content_length_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_content_length_trampoline<F: Fn(&URIResponse) + 'static>(
            this: *mut ffi::WebKitURIResponse,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::content-length".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_content_length_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "http-headers")]
    pub fn connect_http_headers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_http_headers_trampoline<F: Fn(&URIResponse) + 'static>(
            this: *mut ffi::WebKitURIResponse,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::http-headers".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_http_headers_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "mime-type")]
    pub fn connect_mime_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_mime_type_trampoline<F: Fn(&URIResponse) + 'static>(
            this: *mut ffi::WebKitURIResponse,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::mime-type".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_mime_type_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "status-code")]
    pub fn connect_status_code_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_status_code_trampoline<F: Fn(&URIResponse) + 'static>(
            this: *mut ffi::WebKitURIResponse,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::status-code".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_status_code_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "suggested-filename")]
    pub fn connect_suggested_filename_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_suggested_filename_trampoline<F: Fn(&URIResponse) + 'static>(
            this: *mut ffi::WebKitURIResponse,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::suggested-filename".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_suggested_filename_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "uri")]
    pub fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_uri_trampoline<F: Fn(&URIResponse) + 'static>(
            this: *mut ffi::WebKitURIResponse,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(&from_glib_borrow(this))
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::uri".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_uri_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}