soup/auto/
hsts_policy.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, Message};
7use glib::translate::*;
8
9glib::wrapper! {
10    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
11    pub struct HSTSPolicy(Boxed<ffi::SoupHSTSPolicy>);
12
13    match fn {
14        copy => |ptr| ffi::soup_hsts_policy_copy(mut_override(ptr)),
15        free => |ptr| ffi::soup_hsts_policy_free(ptr),
16        type_ => || ffi::soup_hsts_policy_get_type(),
17    }
18}
19
20impl HSTSPolicy {
21    #[doc(alias = "soup_hsts_policy_new")]
22    pub fn new(domain: &str, max_age: libc::c_ulong, include_subdomains: bool) -> HSTSPolicy {
23        assert_initialized_main_thread!();
24        unsafe {
25            from_glib_full(ffi::soup_hsts_policy_new(
26                domain.to_glib_none().0,
27                max_age,
28                include_subdomains.into_glib(),
29            ))
30        }
31    }
32
33    #[doc(alias = "soup_hsts_policy_new_from_response")]
34    #[doc(alias = "new_from_response")]
35    pub fn from_response(msg: &Message) -> Option<HSTSPolicy> {
36        skip_assert_initialized!();
37        unsafe {
38            from_glib_full(ffi::soup_hsts_policy_new_from_response(
39                msg.to_glib_none().0,
40            ))
41        }
42    }
43
44    #[doc(alias = "soup_hsts_policy_new_full")]
45    pub fn new_full(
46        domain: &str,
47        max_age: libc::c_ulong,
48        expires: &glib::DateTime,
49        include_subdomains: bool,
50    ) -> HSTSPolicy {
51        assert_initialized_main_thread!();
52        unsafe {
53            from_glib_full(ffi::soup_hsts_policy_new_full(
54                domain.to_glib_none().0,
55                max_age,
56                expires.to_glib_none().0,
57                include_subdomains.into_glib(),
58            ))
59        }
60    }
61
62    #[doc(alias = "soup_hsts_policy_new_session_policy")]
63    pub fn new_session_policy(domain: &str, include_subdomains: bool) -> HSTSPolicy {
64        assert_initialized_main_thread!();
65        unsafe {
66            from_glib_full(ffi::soup_hsts_policy_new_session_policy(
67                domain.to_glib_none().0,
68                include_subdomains.into_glib(),
69            ))
70        }
71    }
72
73    #[doc(alias = "soup_hsts_policy_get_domain")]
74    #[doc(alias = "get_domain")]
75    pub fn domain(&mut self) -> Option<glib::GString> {
76        unsafe { from_glib_none(ffi::soup_hsts_policy_get_domain(self.to_glib_none_mut().0)) }
77    }
78
79    #[doc(alias = "soup_hsts_policy_get_expires")]
80    #[doc(alias = "get_expires")]
81    pub fn expires(&mut self) -> Option<glib::DateTime> {
82        unsafe { from_glib_full(ffi::soup_hsts_policy_get_expires(self.to_glib_none_mut().0)) }
83    }
84
85    #[doc(alias = "soup_hsts_policy_get_max_age")]
86    #[doc(alias = "get_max_age")]
87    pub fn max_age(&mut self) -> libc::c_ulong {
88        unsafe { ffi::soup_hsts_policy_get_max_age(self.to_glib_none_mut().0) }
89    }
90
91    #[doc(alias = "soup_hsts_policy_includes_subdomains")]
92    pub fn includes_subdomains(&mut self) -> bool {
93        unsafe {
94            from_glib(ffi::soup_hsts_policy_includes_subdomains(
95                self.to_glib_none_mut().0,
96            ))
97        }
98    }
99
100    #[doc(alias = "soup_hsts_policy_is_expired")]
101    pub fn is_expired(&mut self) -> bool {
102        unsafe { from_glib(ffi::soup_hsts_policy_is_expired(self.to_glib_none_mut().0)) }
103    }
104
105    #[doc(alias = "soup_hsts_policy_is_session_policy")]
106    pub fn is_session_policy(&mut self) -> bool {
107        unsafe {
108            from_glib(ffi::soup_hsts_policy_is_session_policy(
109                self.to_glib_none_mut().0,
110            ))
111        }
112    }
113}