gio/auto/
tls_password.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// DO NOT EDIT
4
5use crate::{ffi, TlsPasswordFlags};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// An abstract interface representing a password used in TLS. Often used in
15    /// user interaction such as unlocking a key storage token.
16    ///
17    /// ## Properties
18    ///
19    ///
20    /// #### `description`
21    ///  Description of what the password is for.
22    ///
23    /// Readable | Writeable
24    ///
25    ///
26    /// #### `flags`
27    ///  Flags about the password.
28    ///
29    /// Readable | Writeable
30    ///
31    ///
32    /// #### `warning`
33    ///  Warning about the password.
34    ///
35    /// Readable | Writeable
36    ///
37    /// # Implements
38    ///
39    /// [`TlsPasswordExt`][trait@crate::prelude::TlsPasswordExt], [`trait@glib::ObjectExt`]
40    #[doc(alias = "GTlsPassword")]
41    pub struct TlsPassword(Object<ffi::GTlsPassword, ffi::GTlsPasswordClass>);
42
43    match fn {
44        type_ => || ffi::g_tls_password_get_type(),
45    }
46}
47
48impl TlsPassword {
49    pub const NONE: Option<&'static TlsPassword> = None;
50
51    /// Create a new #GTlsPassword object.
52    /// ## `flags`
53    /// the password flags
54    /// ## `description`
55    /// description of what the password is for
56    ///
57    /// # Returns
58    ///
59    /// The newly allocated password object
60    #[doc(alias = "g_tls_password_new")]
61    pub fn new(flags: TlsPasswordFlags, description: &str) -> TlsPassword {
62        unsafe {
63            from_glib_full(ffi::g_tls_password_new(
64                flags.into_glib(),
65                description.to_glib_none().0,
66            ))
67        }
68    }
69}
70
71/// Trait containing all [`struct@TlsPassword`] methods.
72///
73/// # Implementors
74///
75/// [`TlsPassword`][struct@crate::TlsPassword]
76pub trait TlsPasswordExt: IsA<TlsPassword> + 'static {
77    /// Get a description string about what the password will be used for.
78    ///
79    /// # Returns
80    ///
81    /// The description of the password.
82    #[doc(alias = "g_tls_password_get_description")]
83    #[doc(alias = "get_description")]
84    fn description(&self) -> glib::GString {
85        unsafe {
86            from_glib_none(ffi::g_tls_password_get_description(
87                self.as_ref().to_glib_none().0,
88            ))
89        }
90    }
91
92    /// Get flags about the password.
93    ///
94    /// # Returns
95    ///
96    /// The flags about the password.
97    #[doc(alias = "g_tls_password_get_flags")]
98    #[doc(alias = "get_flags")]
99    fn flags(&self) -> TlsPasswordFlags {
100        unsafe {
101            from_glib(ffi::g_tls_password_get_flags(
102                self.as_ref().to_glib_none().0,
103            ))
104        }
105    }
106
107    /// Get a user readable translated warning. Usually this warning is a
108    /// representation of the password flags returned from
109    /// g_tls_password_get_flags().
110    ///
111    /// # Returns
112    ///
113    /// The warning.
114    #[doc(alias = "g_tls_password_get_warning")]
115    #[doc(alias = "get_warning")]
116    fn warning(&self) -> glib::GString {
117        unsafe {
118            from_glib_none(ffi::g_tls_password_get_warning(
119                self.as_ref().to_glib_none().0,
120            ))
121        }
122    }
123
124    /// Set a description string about what the password will be used for.
125    /// ## `description`
126    /// The description of the password
127    #[doc(alias = "g_tls_password_set_description")]
128    #[doc(alias = "description")]
129    fn set_description(&self, description: &str) {
130        unsafe {
131            ffi::g_tls_password_set_description(
132                self.as_ref().to_glib_none().0,
133                description.to_glib_none().0,
134            );
135        }
136    }
137
138    /// Set flags about the password.
139    /// ## `flags`
140    /// The flags about the password
141    #[doc(alias = "g_tls_password_set_flags")]
142    #[doc(alias = "flags")]
143    fn set_flags(&self, flags: TlsPasswordFlags) {
144        unsafe {
145            ffi::g_tls_password_set_flags(self.as_ref().to_glib_none().0, flags.into_glib());
146        }
147    }
148
149    //#[doc(alias = "g_tls_password_set_value_full")]
150    //fn set_value_full(&self, value: &[u8]) {
151    //    unsafe { TODO: call ffi:g_tls_password_set_value_full() }
152    //}
153
154    /// Set a user readable translated warning. Usually this warning is a
155    /// representation of the password flags returned from
156    /// g_tls_password_get_flags().
157    /// ## `warning`
158    /// The user readable warning
159    #[doc(alias = "g_tls_password_set_warning")]
160    #[doc(alias = "warning")]
161    fn set_warning(&self, warning: &str) {
162        unsafe {
163            ffi::g_tls_password_set_warning(
164                self.as_ref().to_glib_none().0,
165                warning.to_glib_none().0,
166            );
167        }
168    }
169
170    #[doc(alias = "description")]
171    fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
172        unsafe extern "C" fn notify_description_trampoline<
173            P: IsA<TlsPassword>,
174            F: Fn(&P) + 'static,
175        >(
176            this: *mut ffi::GTlsPassword,
177            _param_spec: glib::ffi::gpointer,
178            f: glib::ffi::gpointer,
179        ) {
180            let f: &F = &*(f as *const F);
181            f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
182        }
183        unsafe {
184            let f: Box_<F> = Box_::new(f);
185            connect_raw(
186                self.as_ptr() as *mut _,
187                c"notify::description".as_ptr() as *const _,
188                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
189                    notify_description_trampoline::<Self, F> as *const (),
190                )),
191                Box_::into_raw(f),
192            )
193        }
194    }
195
196    #[doc(alias = "flags")]
197    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
198        unsafe extern "C" fn notify_flags_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
199            this: *mut ffi::GTlsPassword,
200            _param_spec: glib::ffi::gpointer,
201            f: glib::ffi::gpointer,
202        ) {
203            let f: &F = &*(f as *const F);
204            f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
205        }
206        unsafe {
207            let f: Box_<F> = Box_::new(f);
208            connect_raw(
209                self.as_ptr() as *mut _,
210                c"notify::flags".as_ptr() as *const _,
211                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
212                    notify_flags_trampoline::<Self, F> as *const (),
213                )),
214                Box_::into_raw(f),
215            )
216        }
217    }
218
219    #[doc(alias = "warning")]
220    fn connect_warning_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
221        unsafe extern "C" fn notify_warning_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
222            this: *mut ffi::GTlsPassword,
223            _param_spec: glib::ffi::gpointer,
224            f: glib::ffi::gpointer,
225        ) {
226            let f: &F = &*(f as *const F);
227            f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
228        }
229        unsafe {
230            let f: Box_<F> = Box_::new(f);
231            connect_raw(
232                self.as_ptr() as *mut _,
233                c"notify::warning".as_ptr() as *const _,
234                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
235                    notify_warning_trampoline::<Self, F> as *const (),
236                )),
237                Box_::into_raw(f),
238            )
239        }
240    }
241}
242
243impl<O: IsA<TlsPassword>> TlsPasswordExt for O {}