// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IDBusObject {
  fn as_dbus_object(Self) -> DBusObject
  fn get_interface(Self, String) -> DBusInterface? = _
  fn get_interfaces(Self) -> Array[DBusInterface] = _
  fn get_object_path(Self) -> String = _
}

///|
pub impl IDBusObject for DBusObject with fn as_dbus_object(self) {
  self
}

///|
/// Implementation contract for DBusObject.interface_added. Self is the retained MoonBit state; the second parameter is the invoked DBusObject object.
pub(open) trait VDBusObjectInterfaceAdded {
  fn interface_added(Self, DBusObject, &IDBusInterface) -> Unit
}

///|
/// Implementation contract for DBusObject.interface_removed. Self is the retained MoonBit state; the second parameter is the invoked DBusObject object.
pub(open) trait VDBusObjectInterfaceRemoved {
  fn interface_removed(Self, DBusObject, &IDBusInterface) -> Unit
}

///|
#borrow(self_, interface_name)
extern "c" fn moonbit_g_dbus_object_get_interface(
  self_ : DBusObject,
  interface_name : Bytes,
) -> @glib.Nullable[DBusInterface] = "moonbit_g_dbus_object_get_interface"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.DBusObject.get_interface.html).
pub fn DBusObject::get_interface(
  self : DBusObject,
  interface_name : String,
) -> DBusInterface? {
  let raw_result = moonbit_g_dbus_object_get_interface(
    self,
    @encoding/utf8.encode(interface_name),
  )
  raw_result.to_option()
}

///|
#borrow(self_, result)
extern "c" fn moonbit_g_dbus_object_get_interfaces(
  self_ : DBusObject,
  result : Ref[FixedArray[DBusInterface]],
) = "moonbit_g_dbus_object_get_interfaces"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.DBusObject.get_interfaces.html).
pub fn DBusObject::get_interfaces(self : DBusObject) -> Array[DBusInterface] {
  let result_ref : Ref[FixedArray[DBusInterface]] = Ref([])
  moonbit_g_dbus_object_get_interfaces(self, result_ref)
  let values : Array[DBusInterface] = Array::new(
    capacity=result_ref.val.length(),
  )
  for value in result_ref.val {
    values.push(value)
  }
  values
}

///|
#borrow(self_)
extern "c" fn moonbit_g_dbus_object_get_object_path(
  self_ : DBusObject,
) -> Bytes = "moonbit_g_dbus_object_get_object_path"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.DBusObject.get_object_path.html).
pub fn DBusObject::get_object_path(self : DBusObject) -> String {
  @encoding/utf8.decode_lossy(moonbit_g_dbus_object_get_object_path(self))
}

///|
impl IDBusObject with fn get_interface(self, interface_name) -> DBusInterface? {
  self.as_dbus_object().get_interface(interface_name)
}

///|
impl IDBusObject with fn get_interfaces(self) -> Array[DBusInterface] {
  self.as_dbus_object().get_interfaces()
}

///|
impl IDBusObject with fn get_object_path(self) -> String {
  self.as_dbus_object().get_object_path()
}