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
114
115
116
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/tauri-apps/gir-files)
// DO NOT EDIT

use crate::CredentialPersistence;
#[cfg(feature = "v2_34")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
use glib::prelude::*;
use glib::translate::*;

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

    match fn {
        copy => |ptr| ffi::webkit_credential_copy(mut_override(ptr)),
        free => |ptr| ffi::webkit_credential_free(ptr),
        type_ => || ffi::webkit_credential_get_type(),
    }
}

impl Credential {
  #[doc(alias = "webkit_credential_new")]
  pub fn new(username: &str, password: &str, persistence: CredentialPersistence) -> Credential {
    assert_initialized_main_thread!();
    unsafe {
      from_glib_full(ffi::webkit_credential_new(
        username.to_glib_none().0,
        password.to_glib_none().0,
        persistence.into_glib(),
      ))
    }
  }

  #[cfg(feature = "v2_34")]
  #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
  #[doc(alias = "webkit_credential_new_for_certificate")]
  #[doc(alias = "new_for_certificate")]
  pub fn for_certificate(
    certificate: Option<&impl IsA<gio::TlsCertificate>>,
    persistence: CredentialPersistence,
  ) -> Credential {
    assert_initialized_main_thread!();
    unsafe {
      from_glib_full(ffi::webkit_credential_new_for_certificate(
        certificate.map(|p| p.as_ref()).to_glib_none().0,
        persistence.into_glib(),
      ))
    }
  }

  #[cfg(feature = "v2_34")]
  #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
  #[doc(alias = "webkit_credential_new_for_certificate_pin")]
  #[doc(alias = "new_for_certificate_pin")]
  pub fn for_certificate_pin(pin: &str, persistence: CredentialPersistence) -> Credential {
    assert_initialized_main_thread!();
    unsafe {
      from_glib_full(ffi::webkit_credential_new_for_certificate_pin(
        pin.to_glib_none().0,
        persistence.into_glib(),
      ))
    }
  }

  #[cfg(feature = "v2_34")]
  #[cfg_attr(docsrs, doc(cfg(feature = "v2_34")))]
  #[doc(alias = "webkit_credential_get_certificate")]
  #[doc(alias = "get_certificate")]
  pub fn certificate(&mut self) -> Option<gio::TlsCertificate> {
    unsafe {
      from_glib_none(ffi::webkit_credential_get_certificate(
        self.to_glib_none_mut().0,
      ))
    }
  }

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

  #[doc(alias = "webkit_credential_get_persistence")]
  #[doc(alias = "get_persistence")]
  pub fn persistence(&mut self) -> CredentialPersistence {
    unsafe {
      from_glib(ffi::webkit_credential_get_persistence(
        self.to_glib_none_mut().0,
      ))
    }
  }

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

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