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
71mod sealed {
72    pub trait Sealed {}
73    impl<T: super::IsA<super::TlsPassword>> Sealed for T {}
74}
75
76/// Trait containing all [`struct@TlsPassword`] methods.
77///
78/// # Implementors
79///
80/// [`TlsPassword`][struct@crate::TlsPassword]
81pub trait TlsPasswordExt: IsA<TlsPassword> + sealed::Sealed + 'static {
82    /// Get a description string about what the password will be used for.
83    ///
84    /// # Returns
85    ///
86    /// The description of the password.
87    #[doc(alias = "g_tls_password_get_description")]
88    #[doc(alias = "get_description")]
89    fn description(&self) -> glib::GString {
90        unsafe {
91            from_glib_none(ffi::g_tls_password_get_description(
92                self.as_ref().to_glib_none().0,
93            ))
94        }
95    }
96
97    /// Get flags about the password.
98    ///
99    /// # Returns
100    ///
101    /// The flags about the password.
102    #[doc(alias = "g_tls_password_get_flags")]
103    #[doc(alias = "get_flags")]
104    fn flags(&self) -> TlsPasswordFlags {
105        unsafe {
106            from_glib(ffi::g_tls_password_get_flags(
107                self.as_ref().to_glib_none().0,
108            ))
109        }
110    }
111
112    /// Get a user readable translated warning. Usually this warning is a
113    /// representation of the password flags returned from
114    /// g_tls_password_get_flags().
115    ///
116    /// # Returns
117    ///
118    /// The warning.
119    #[doc(alias = "g_tls_password_get_warning")]
120    #[doc(alias = "get_warning")]
121    fn warning(&self) -> glib::GString {
122        unsafe {
123            from_glib_none(ffi::g_tls_password_get_warning(
124                self.as_ref().to_glib_none().0,
125            ))
126        }
127    }
128
129    /// Set a description string about what the password will be used for.
130    /// ## `description`
131    /// The description of the password
132    #[doc(alias = "g_tls_password_set_description")]
133    #[doc(alias = "description")]
134    fn set_description(&self, description: &str) {
135        unsafe {
136            ffi::g_tls_password_set_description(
137                self.as_ref().to_glib_none().0,
138                description.to_glib_none().0,
139            );
140        }
141    }
142
143    /// Set flags about the password.
144    /// ## `flags`
145    /// The flags about the password
146    #[doc(alias = "g_tls_password_set_flags")]
147    #[doc(alias = "flags")]
148    fn set_flags(&self, flags: TlsPasswordFlags) {
149        unsafe {
150            ffi::g_tls_password_set_flags(self.as_ref().to_glib_none().0, flags.into_glib());
151        }
152    }
153
154    //#[doc(alias = "g_tls_password_set_value_full")]
155    //fn set_value_full(&self, value: &[u8]) {
156    //    unsafe { TODO: call ffi:g_tls_password_set_value_full() }
157    //}
158
159    /// Set a user readable translated warning. Usually this warning is a
160    /// representation of the password flags returned from
161    /// g_tls_password_get_flags().
162    /// ## `warning`
163    /// The user readable warning
164    #[doc(alias = "g_tls_password_set_warning")]
165    #[doc(alias = "warning")]
166    fn set_warning(&self, warning: &str) {
167        unsafe {
168            ffi::g_tls_password_set_warning(
169                self.as_ref().to_glib_none().0,
170                warning.to_glib_none().0,
171            );
172        }
173    }
174
175    #[doc(alias = "description")]
176    fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
177        unsafe extern "C" fn notify_description_trampoline<
178            P: IsA<TlsPassword>,
179            F: Fn(&P) + 'static,
180        >(
181            this: *mut ffi::GTlsPassword,
182            _param_spec: glib::ffi::gpointer,
183            f: glib::ffi::gpointer,
184        ) {
185            let f: &F = &*(f as *const F);
186            f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
187        }
188        unsafe {
189            let f: Box_<F> = Box_::new(f);
190            connect_raw(
191                self.as_ptr() as *mut _,
192                b"notify::description\0".as_ptr() as *const _,
193                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
194                    notify_description_trampoline::<Self, F> as *const (),
195                )),
196                Box_::into_raw(f),
197            )
198        }
199    }
200
201    #[doc(alias = "flags")]
202    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
203        unsafe extern "C" fn notify_flags_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
204            this: *mut ffi::GTlsPassword,
205            _param_spec: glib::ffi::gpointer,
206            f: glib::ffi::gpointer,
207        ) {
208            let f: &F = &*(f as *const F);
209            f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
210        }
211        unsafe {
212            let f: Box_<F> = Box_::new(f);
213            connect_raw(
214                self.as_ptr() as *mut _,
215                b"notify::flags\0".as_ptr() as *const _,
216                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
217                    notify_flags_trampoline::<Self, F> as *const (),
218                )),
219                Box_::into_raw(f),
220            )
221        }
222    }
223
224    #[doc(alias = "warning")]
225    fn connect_warning_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
226        unsafe extern "C" fn notify_warning_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
227            this: *mut ffi::GTlsPassword,
228            _param_spec: glib::ffi::gpointer,
229            f: glib::ffi::gpointer,
230        ) {
231            let f: &F = &*(f as *const F);
232            f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
233        }
234        unsafe {
235            let f: Box_<F> = Box_::new(f);
236            connect_raw(
237                self.as_ptr() as *mut _,
238                b"notify::warning\0".as_ptr() as *const _,
239                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
240                    notify_warning_trampoline::<Self, F> as *const (),
241                )),
242                Box_::into_raw(f),
243            )
244        }
245    }
246}
247
248impl<O: IsA<TlsPassword>> TlsPasswordExt for O {}