1use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 #[doc(alias = "GCredentials")]
10 pub struct Credentials(Object<ffi::GCredentials, ffi::GCredentialsClass>);
11
12 match fn {
13 type_ => || ffi::g_credentials_get_type(),
14 }
15}
16
17impl Credentials {
18 #[doc(alias = "g_credentials_new")]
19 pub fn new() -> Credentials {
20 unsafe { from_glib_full(ffi::g_credentials_new()) }
21 }
22
23 #[doc(alias = "g_credentials_is_same_user")]
24 pub fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), glib::Error> {
25 unsafe {
26 let mut error = std::ptr::null_mut();
27 let is_ok = ffi::g_credentials_is_same_user(
28 self.to_glib_none().0,
29 other_credentials.to_glib_none().0,
30 &mut error,
31 );
32 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
33 if error.is_null() {
34 Ok(())
35 } else {
36 Err(from_glib_full(error))
37 }
38 }
39 }
40
41 #[doc(alias = "g_credentials_to_string")]
42 #[doc(alias = "to_string")]
43 pub fn to_str(&self) -> glib::GString {
44 unsafe { from_glib_full(ffi::g_credentials_to_string(self.to_glib_none().0)) }
45 }
46}
47
48impl Default for Credentials {
49 fn default() -> Self {
50 Self::new()
51 }
52}
53
54impl std::fmt::Display for Credentials {
55 #[inline]
56 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
57 f.write_str(&self.to_str())
58 }
59}