gio/auto/
tls_password.rs
1use 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 #[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 #[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
76pub trait TlsPasswordExt: IsA<TlsPassword> + sealed::Sealed + 'static {
82 #[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 #[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 #[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 #[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 #[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_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 {}