// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IUnixFDList {
  fn as_unix_fd_list(Self) -> UnixFDList
  fn append(Self, Int) -> Int raise @glib.Error_ = _
  fn get(Self, Int) -> Int raise @glib.Error_ = _
  fn get_length(Self) -> Int = _
  fn peek_fds(Self) -> Array[Int] = _
  fn steal_fds(Self) -> Array[Int] = _
}

///|
pub impl IUnixFDList for UnixFDList with fn as_unix_fd_list(self) {
  self
}

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

///|
#borrow(self_, error)
extern "c" fn moonbit_g_unix_fd_list_append(
  self_ : UnixFDList,
  fd : Int,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Int = "moonbit_g_unix_fd_list_append"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.UnixFDList.append.html).
pub fn UnixFDList::append(
  self : UnixFDList,
  fd : Int,
) -> Int raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_g_unix_fd_list_append(self, fd, error_)
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  result
}

///|
#borrow(self_, error)
extern "c" fn moonbit_g_unix_fd_list_get(
  self_ : UnixFDList,
  index_ : Int,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> Int = "moonbit_g_unix_fd_list_get"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.UnixFDList.get.html).
pub fn UnixFDList::get(
  self : UnixFDList,
  index_ : Int,
) -> Int raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_g_unix_fd_list_get(self, index_, error_)
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  result
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.UnixFDList.get_length.html).
#borrow(self)
pub extern "c" fn UnixFDList::get_length(self : UnixFDList) -> Int = "moonbit_g_unix_fd_list_get_length"

///|
#borrow(self_, result)
extern "c" fn moonbit_g_unix_fd_list_peek_fds(
  self_ : UnixFDList,
  result : Ref[FixedArray[Int]],
) = "moonbit_g_unix_fd_list_peek_fds"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.UnixFDList.peek_fds.html).
pub fn UnixFDList::peek_fds(self : UnixFDList) -> Array[Int] {
  let result_ref : Ref[FixedArray[Int]] = Ref([])
  moonbit_g_unix_fd_list_peek_fds(self, result_ref)
  let values : Array[Int] = Array::new(capacity=result_ref.val.length())
  for i in 0.. Array[Int] {
  let result_ref : Ref[FixedArray[Int]] = Ref([])
  moonbit_g_unix_fd_list_steal_fds(self, result_ref)
  let values : Array[Int] = Array::new(capacity=result_ref.val.length())
  for i in 0.. Int raise @glib.Error_ {
  self.as_unix_fd_list().append(fd)
}

///|
impl IUnixFDList with fn get(self, index_) -> Int raise @glib.Error_ {
  self.as_unix_fd_list().get(index_)
}

///|
impl IUnixFDList with fn get_length(self) -> Int {
  self.as_unix_fd_list().get_length()
}

///|
impl IUnixFDList with fn peek_fds(self) -> Array[Int] {
  self.as_unix_fd_list().peek_fds()
}

///|
impl IUnixFDList with fn steal_fds(self) -> Array[Int] {
  self.as_unix_fd_list().steal_fds()
}

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

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