// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IMount {
  fn as_mount(Self) -> Mount
  fn can_eject(Self) -> Bool = _
  fn can_unmount(Self) -> Bool = _
  fn get_default_location(Self) -> File = _
  fn get_drive(Self) -> Drive? = _
  fn get_icon(Self) -> Icon = _
  fn get_name(Self) -> String = _
  fn get_root(Self) -> File = _
  fn get_sort_key(Self) -> String? = _
  fn get_symbolic_icon(Self) -> Icon = _
  fn get_uuid(Self) -> String? = _
  fn get_volume(Self) -> Volume? = _
  fn is_shadowed(Self) -> Bool = _
  fn shadow(Self) -> Unit = _
  fn unshadow(Self) -> Unit = _
  fn eject_with_operation(
    Self,
    MountUnmountFlags,
    &IMountOperation?,
    &ICancellable?,
    (Result[Bool, @glib.Error_]) -> Unit,
  ) -> Unit = _
  fn remount(
    Self,
    MountMountFlags,
    &IMountOperation?,
    &ICancellable?,
    (Result[Bool, @glib.Error_]) -> Unit,
  ) -> Unit = _
  fn unmount_with_operation(
    Self,
    MountUnmountFlags,
    &IMountOperation?,
    &ICancellable?,
    (Result[Bool, @glib.Error_]) -> Unit,
  ) -> Unit = _
}

///|
pub impl IMount for Mount with fn as_mount(self) {
  self
}

///|
/// Implementation contract for Mount.changed. Self is the retained MoonBit state; the second parameter is the invoked Mount object.
pub(open) trait VMountChanged {
  fn changed(Self, Mount) -> Unit
}

///|
/// Implementation contract for Mount.pre_unmount. Self is the retained MoonBit state; the second parameter is the invoked Mount object.
pub(open) trait VMountPreUnmount {
  fn pre_unmount(Self, Mount) -> Unit
}

///|
/// Implementation contract for Mount.unmounted. Self is the retained MoonBit state; the second parameter is the invoked Mount object.
pub(open) trait VMountUnmounted {
  fn unmounted(Self, Mount) -> Unit
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.can_eject.html).
#borrow(self)
pub extern "c" fn Mount::can_eject(self : Mount) -> Bool = "moonbit_g_mount_can_eject"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.can_unmount.html).
#borrow(self)
pub extern "c" fn Mount::can_unmount(self : Mount) -> Bool = "moonbit_g_mount_can_unmount"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_default_location.html).
#borrow(self)
pub extern "c" fn Mount::get_default_location(self : Mount) -> File = "moonbit_g_mount_get_default_location"

///|
#borrow(self_)
extern "c" fn moonbit_g_mount_get_drive(self_ : Mount) -> @glib.Nullable[Drive] = "moonbit_g_mount_get_drive"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_drive.html).
pub fn Mount::get_drive(self : Mount) -> Drive? {
  let raw_result = moonbit_g_mount_get_drive(self)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_icon.html).
#borrow(self)
pub extern "c" fn Mount::get_icon(self : Mount) -> Icon = "moonbit_g_mount_get_icon"

///|
#borrow(self_)
extern "c" fn moonbit_g_mount_get_name(self_ : Mount) -> Bytes = "moonbit_g_mount_get_name"

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

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_root.html).
#borrow(self)
pub extern "c" fn Mount::get_root(self : Mount) -> File = "moonbit_g_mount_get_root"

///|
#borrow(self_)
extern "c" fn moonbit_g_mount_get_sort_key(
  self_ : Mount,
) -> @glib.Nullable[Bytes] = "moonbit_g_mount_get_sort_key"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_sort_key.html).
pub fn Mount::get_sort_key(self : Mount) -> String? {
  let result = moonbit_g_mount_get_sort_key(self)
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_symbolic_icon.html).
#borrow(self)
pub extern "c" fn Mount::get_symbolic_icon(self : Mount) -> Icon = "moonbit_g_mount_get_symbolic_icon"

///|
#borrow(self_)
extern "c" fn moonbit_g_mount_get_uuid(self_ : Mount) -> @glib.Nullable[Bytes] = "moonbit_g_mount_get_uuid"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_uuid.html).
pub fn Mount::get_uuid(self : Mount) -> String? {
  let result = moonbit_g_mount_get_uuid(self)
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(self_)
extern "c" fn moonbit_g_mount_get_volume(
  self_ : Mount,
) -> @glib.Nullable[Volume] = "moonbit_g_mount_get_volume"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.get_volume.html).
pub fn Mount::get_volume(self : Mount) -> Volume? {
  let raw_result = moonbit_g_mount_get_volume(self)
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.is_shadowed.html).
#borrow(self)
pub extern "c" fn Mount::is_shadowed(self : Mount) -> Bool = "moonbit_g_mount_is_shadowed"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.shadow.html).
#borrow(self)
pub extern "c" fn Mount::shadow(self : Mount) = "moonbit_g_mount_shadow"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.unshadow.html).
#borrow(self)
pub extern "c" fn Mount::unshadow(self : Mount) = "moonbit_g_mount_unshadow"

///|
#borrow(self_, mount_operation, cancellable)
extern "c" fn g_mount_eject_with_operation(
  self_ : Mount,
  flags : Int,
  mount_operation : @glib.Nullable[MountOperation],
  cancellable : @glib.Nullable[Cancellable],
  function : FuncRef[
    (
      Bool,
      @glib.Nullable[@glib.Error_],
      (Bool, @glib.Nullable[@glib.Error_]) -> Unit,
    ) -> Unit,
  ],
  closure : (Bool, @glib.Nullable[@glib.Error_]) -> Unit,
) = "moonbit_g_mount_eject_with_operation"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.eject_with_operation.html).
pub fn Mount::eject_with_operation(
  self : Mount,
  flags : MountUnmountFlags,
  mount_operation : &IMountOperation?,
  cancellable : &ICancellable?,
  callback : (Result[Bool, @glib.Error_]) -> Unit,
) -> Unit {
  g_mount_eject_with_operation(
    self,
    flags.to_int(),
    match mount_operation {
      Some(v) => @glib.Nullable::some(v.as_mount_operation())
      None => @glib.Nullable::null()
    },
    match cancellable {
      Some(v) => @glib.Nullable::some(v.as_cancellable())
      None => @glib.Nullable::null()
    },
    fn(result, error, f) { f(result, error) },
    fn(result, error) {
      match error.to_option() {
        Some(e) => callback(Err(e))
        None => callback(Ok(result))
      }
    },
  )
}

///|
#borrow(self_, mount_operation, cancellable)
extern "c" fn g_mount_remount(
  self_ : Mount,
  flags : Int,
  mount_operation : @glib.Nullable[MountOperation],
  cancellable : @glib.Nullable[Cancellable],
  function : FuncRef[
    (
      Bool,
      @glib.Nullable[@glib.Error_],
      (Bool, @glib.Nullable[@glib.Error_]) -> Unit,
    ) -> Unit,
  ],
  closure : (Bool, @glib.Nullable[@glib.Error_]) -> Unit,
) = "moonbit_g_mount_remount"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.remount.html).
pub fn Mount::remount(
  self : Mount,
  flags : MountMountFlags,
  mount_operation : &IMountOperation?,
  cancellable : &ICancellable?,
  callback : (Result[Bool, @glib.Error_]) -> Unit,
) -> Unit {
  g_mount_remount(
    self,
    flags.to_int(),
    match mount_operation {
      Some(v) => @glib.Nullable::some(v.as_mount_operation())
      None => @glib.Nullable::null()
    },
    match cancellable {
      Some(v) => @glib.Nullable::some(v.as_cancellable())
      None => @glib.Nullable::null()
    },
    fn(result, error, f) { f(result, error) },
    fn(result, error) {
      match error.to_option() {
        Some(e) => callback(Err(e))
        None => callback(Ok(result))
      }
    },
  )
}

///|
#borrow(self_, mount_operation, cancellable)
extern "c" fn g_mount_unmount_with_operation(
  self_ : Mount,
  flags : Int,
  mount_operation : @glib.Nullable[MountOperation],
  cancellable : @glib.Nullable[Cancellable],
  function : FuncRef[
    (
      Bool,
      @glib.Nullable[@glib.Error_],
      (Bool, @glib.Nullable[@glib.Error_]) -> Unit,
    ) -> Unit,
  ],
  closure : (Bool, @glib.Nullable[@glib.Error_]) -> Unit,
) = "moonbit_g_mount_unmount_with_operation"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.Mount.unmount_with_operation.html).
pub fn Mount::unmount_with_operation(
  self : Mount,
  flags : MountUnmountFlags,
  mount_operation : &IMountOperation?,
  cancellable : &ICancellable?,
  callback : (Result[Bool, @glib.Error_]) -> Unit,
) -> Unit {
  g_mount_unmount_with_operation(
    self,
    flags.to_int(),
    match mount_operation {
      Some(v) => @glib.Nullable::some(v.as_mount_operation())
      None => @glib.Nullable::null()
    },
    match cancellable {
      Some(v) => @glib.Nullable::some(v.as_cancellable())
      None => @glib.Nullable::null()
    },
    fn(result, error, f) { f(result, error) },
    fn(result, error) {
      match error.to_option() {
        Some(e) => callback(Err(e))
        None => callback(Ok(result))
      }
    },
  )
}

///|
impl IMount with fn can_eject(self) -> Bool {
  self.as_mount().can_eject()
}

///|
impl IMount with fn can_unmount(self) -> Bool {
  self.as_mount().can_unmount()
}

///|
impl IMount with fn get_default_location(self) -> File {
  self.as_mount().get_default_location()
}

///|
impl IMount with fn get_drive(self) -> Drive? {
  self.as_mount().get_drive()
}

///|
impl IMount with fn get_icon(self) -> Icon {
  self.as_mount().get_icon()
}

///|
impl IMount with fn get_name(self) -> String {
  self.as_mount().get_name()
}

///|
impl IMount with fn get_root(self) -> File {
  self.as_mount().get_root()
}

///|
impl IMount with fn get_sort_key(self) -> String? {
  self.as_mount().get_sort_key()
}

///|
impl IMount with fn get_symbolic_icon(self) -> Icon {
  self.as_mount().get_symbolic_icon()
}

///|
impl IMount with fn get_uuid(self) -> String? {
  self.as_mount().get_uuid()
}

///|
impl IMount with fn get_volume(self) -> Volume? {
  self.as_mount().get_volume()
}

///|
impl IMount with fn is_shadowed(self) -> Bool {
  self.as_mount().is_shadowed()
}

///|
impl IMount with fn shadow(self) -> Unit {
  self.as_mount().shadow()
}

///|
impl IMount with fn unshadow(self) -> Unit {
  self.as_mount().unshadow()
}

///|
impl IMount with fn eject_with_operation(
  self,
  flags,
  mount_operation,
  cancellable,
  callback,
) -> Unit {
  self
  .as_mount()
  .eject_with_operation(flags, mount_operation, cancellable, callback)
}

///|
impl IMount with fn remount(self, flags, mount_operation, cancellable, callback) -> Unit {
  self.as_mount().remount(flags, mount_operation, cancellable, callback)
}

///|
impl IMount with fn unmount_with_operation(
  self,
  flags,
  mount_operation,
  cancellable,
  callback,
) -> Unit {
  self
  .as_mount()
  .unmount_with_operation(flags, mount_operation, cancellable, callback)
}