1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, Message};
use glib::translate::*;

glib::wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct HSTSPolicy(Boxed<ffi::SoupHSTSPolicy>);

    match fn {
        copy => |ptr| ffi::soup_hsts_policy_copy(mut_override(ptr)),
        free => |ptr| ffi::soup_hsts_policy_free(ptr),
        type_ => || ffi::soup_hsts_policy_get_type(),
    }
}

impl HSTSPolicy {
    #[doc(alias = "soup_hsts_policy_new")]
    pub fn new(domain: &str, max_age: libc::c_ulong, include_subdomains: bool) -> HSTSPolicy {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::soup_hsts_policy_new(
                domain.to_glib_none().0,
                max_age,
                include_subdomains.into_glib(),
            ))
        }
    }

    #[doc(alias = "soup_hsts_policy_new_from_response")]
    #[doc(alias = "new_from_response")]
    pub fn from_response(msg: &Message) -> Option<HSTSPolicy> {
        skip_assert_initialized!();
        unsafe {
            from_glib_full(ffi::soup_hsts_policy_new_from_response(
                msg.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "soup_hsts_policy_new_full")]
    pub fn new_full(
        domain: &str,
        max_age: libc::c_ulong,
        expires: &glib::DateTime,
        include_subdomains: bool,
    ) -> HSTSPolicy {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::soup_hsts_policy_new_full(
                domain.to_glib_none().0,
                max_age,
                expires.to_glib_none().0,
                include_subdomains.into_glib(),
            ))
        }
    }

    #[doc(alias = "soup_hsts_policy_new_session_policy")]
    pub fn new_session_policy(domain: &str, include_subdomains: bool) -> HSTSPolicy {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::soup_hsts_policy_new_session_policy(
                domain.to_glib_none().0,
                include_subdomains.into_glib(),
            ))
        }
    }

    #[doc(alias = "soup_hsts_policy_get_domain")]
    #[doc(alias = "get_domain")]
    pub fn domain(&mut self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::soup_hsts_policy_get_domain(self.to_glib_none_mut().0)) }
    }

    #[doc(alias = "soup_hsts_policy_get_expires")]
    #[doc(alias = "get_expires")]
    pub fn expires(&mut self) -> Option<glib::DateTime> {
        unsafe { from_glib_full(ffi::soup_hsts_policy_get_expires(self.to_glib_none_mut().0)) }
    }

    #[doc(alias = "soup_hsts_policy_get_max_age")]
    #[doc(alias = "get_max_age")]
    pub fn max_age(&mut self) -> libc::c_ulong {
        unsafe { ffi::soup_hsts_policy_get_max_age(self.to_glib_none_mut().0) }
    }

    #[doc(alias = "soup_hsts_policy_includes_subdomains")]
    pub fn includes_subdomains(&mut self) -> bool {
        unsafe {
            from_glib(ffi::soup_hsts_policy_includes_subdomains(
                self.to_glib_none_mut().0,
            ))
        }
    }

    #[doc(alias = "soup_hsts_policy_is_expired")]
    pub fn is_expired(&mut self) -> bool {
        unsafe { from_glib(ffi::soup_hsts_policy_is_expired(self.to_glib_none_mut().0)) }
    }

    #[doc(alias = "soup_hsts_policy_is_session_policy")]
    pub fn is_session_policy(&mut self) -> bool {
        unsafe {
            from_glib(ffi::soup_hsts_policy_is_session_policy(
                self.to_glib_none_mut().0,
            ))
        }
    }
}