// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://docs.gtk.org/gio/class.DBusAuthObserver.html).
pub type DBusAuthObserver

///|
pub(open) trait IDBusAuthObserver {
  fn as_dbus_auth_observer(Self) -> DBusAuthObserver
  fn allow_mechanism(Self, String) -> Bool = _
  fn authorize_authenticated_peer(Self, &IIOStream, &ICredentials?) -> Bool = _
  fn connect_allow_mechanism(Self, (DBusAuthObserver, String) -> Bool) -> UInt64 = _
  fn connect_authorize_authenticated_peer(
    Self,
    (DBusAuthObserver, IOStream, Credentials?) -> Bool,
  ) -> UInt64 = _
}

///|
pub impl IDBusAuthObserver for DBusAuthObserver with fn as_dbus_auth_observer(
  self,
) {
  self
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/ctor.DBusAuthObserver.new.html).
pub extern "c" fn DBusAuthObserver::new() -> DBusAuthObserver = "moonbit_g_dbus_auth_observer_new"

///|
#borrow(self_, mechanism)
extern "c" fn moonbit_g_dbus_auth_observer_allow_mechanism(
  self_ : DBusAuthObserver,
  mechanism : Bytes,
) -> Bool = "moonbit_g_dbus_auth_observer_allow_mechanism"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.DBusAuthObserver.allow_mechanism.html).
pub fn DBusAuthObserver::allow_mechanism(
  self : DBusAuthObserver,
  mechanism : String,
) -> Bool {
  moonbit_g_dbus_auth_observer_allow_mechanism(
    self,
    @encoding/utf8.encode(mechanism),
  )
}

///|
#borrow(self_, stream, credentials)
extern "c" fn moonbit_g_dbus_auth_observer_authorize_authenticated_peer(
  self_ : DBusAuthObserver,
  stream : IOStream,
  credentials : @glib.Nullable[Credentials],
) -> Bool = "moonbit_g_dbus_auth_observer_authorize_authenticated_peer"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.DBusAuthObserver.authorize_authenticated_peer.html).
pub fn DBusAuthObserver::authorize_authenticated_peer(
  self : DBusAuthObserver,
  stream : &IIOStream,
  credentials : &ICredentials?,
) -> Bool {
  moonbit_g_dbus_auth_observer_authorize_authenticated_peer(
    self,
    stream.as_io_stream(),
    match credentials {
      Some(v) => @glib.Nullable::some(v.as_credentials())
      None => @glib.Nullable::null()
    },
  )
}

///|
#borrow(instance)
extern "c" fn gd_bus_auth_observer_connect_allow_mechanism(
  instance : DBusAuthObserver,
  function : FuncRef[
    (DBusAuthObserver, Bytes, (DBusAuthObserver, String) -> Bool) -> Bool,
  ],
  closure : (DBusAuthObserver, String) -> Bool,
) -> UInt64 = "moonbit_gd_bus_auth_observer_connect_allow_mechanism"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/signal.DBusAuthObserver.allow-mechanism.html).
pub fn DBusAuthObserver::connect_allow_mechanism(
  self : DBusAuthObserver,
  f : (DBusAuthObserver, String) -> Bool,
) -> UInt64 {
  gd_bus_auth_observer_connect_allow_mechanism(
    self,
    fn(instance_, mechanism, f) {
      f(instance_, @encoding/utf8.decode_lossy(mechanism))
    },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn gd_bus_auth_observer_connect_authorize_authenticated_peer(
  instance : DBusAuthObserver,
  function : FuncRef[
    (
      DBusAuthObserver,
      IOStream,
      Credentials?,
      (DBusAuthObserver, IOStream, Credentials?) -> Bool,
    ) -> Bool,
  ],
  closure : (DBusAuthObserver, IOStream, Credentials?) -> Bool,
) -> UInt64 = "moonbit_gd_bus_auth_observer_connect_authorize_authenticated_peer"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/signal.DBusAuthObserver.authorize-authenticated-peer.html).
pub fn DBusAuthObserver::connect_authorize_authenticated_peer(
  self : DBusAuthObserver,
  f : (DBusAuthObserver, IOStream, Credentials?) -> Bool,
) -> UInt64 {
  gd_bus_auth_observer_connect_authorize_authenticated_peer(
    self,
    fn(instance_, stream, credentials, f) { f(instance_, stream, credentials) },
    f,
  )
}

///|
impl IDBusAuthObserver with fn allow_mechanism(self, mechanism) -> Bool {
  self.as_dbus_auth_observer().allow_mechanism(mechanism)
}

///|
impl IDBusAuthObserver with fn authorize_authenticated_peer(
  self,
  stream,
  credentials,
) -> Bool {
  self.as_dbus_auth_observer().authorize_authenticated_peer(stream, credentials)
}

///|
impl IDBusAuthObserver with fn connect_allow_mechanism(self, f) -> UInt64 {
  self.as_dbus_auth_observer().connect_allow_mechanism(f)
}

///|
impl IDBusAuthObserver with fn connect_authorize_authenticated_peer(self, f) -> UInt64 {
  self.as_dbus_auth_observer().connect_authorize_authenticated_peer(f)
}

///|
pub fn DBusAuthObserver::as_gobject_object(
  self : DBusAuthObserver,
) -> @gobject.Object = "%identity"

///|
pub impl @gobject.IObject for DBusAuthObserver with fn as_object(self) {
  self.as_gobject_object()
}