// GENERATED — DO NOT EDIT

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

///|
pub(open) trait ICharsetConverter {
  fn as_charset_converter(Self) -> CharsetConverter
  fn get_num_fallbacks(Self) -> UInt = _
  fn get_use_fallback(Self) -> Bool = _
  fn set_use_fallback(Self, Bool) -> Unit = _
}

///|
pub impl ICharsetConverter for CharsetConverter with fn as_charset_converter(
  self,
) {
  self
}

///|
#borrow(to_charset, from_charset, error)
extern "c" fn moonbit_g_charset_converter_new(
  to_charset : Bytes,
  from_charset : Bytes,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> CharsetConverter = "moonbit_g_charset_converter_new"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/ctor.CharsetConverter.new.html).
pub fn CharsetConverter::new(
  to_charset : String,
  from_charset : String,
) -> CharsetConverter raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_g_charset_converter_new(
    @encoding/utf8.encode(to_charset),
    @encoding/utf8.encode(from_charset),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => result
  }
}

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.CharsetConverter.get_num_fallbacks.html).
#borrow(self)
pub extern "c" fn CharsetConverter::get_num_fallbacks(
  self : CharsetConverter,
) -> UInt = "moonbit_g_charset_converter_get_num_fallbacks"

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

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.CharsetConverter.set_use_fallback.html).
#borrow(self)
pub extern "c" fn CharsetConverter::set_use_fallback(
  self : CharsetConverter,
  use_fallback : Bool,
) = "moonbit_g_charset_converter_set_use_fallback"

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

///|
/// [Upstream documentation](https://docs.gtk.org/gio/property.CharsetConverter.from-charset.html).
pub fn CharsetConverter::get_from_charset(self : CharsetConverter) -> String {
  @encoding/utf8.decode_lossy(
    moonbit_g_charset_converter_get_from_charset(self),
  )
}

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

///|
/// [Upstream documentation](https://docs.gtk.org/gio/property.CharsetConverter.to-charset.html).
pub fn CharsetConverter::get_to_charset(self : CharsetConverter) -> String {
  @encoding/utf8.decode_lossy(moonbit_g_charset_converter_get_to_charset(self))
}

///|
impl ICharsetConverter with fn get_num_fallbacks(self) -> UInt {
  self.as_charset_converter().get_num_fallbacks()
}

///|
impl ICharsetConverter with fn get_use_fallback(self) -> Bool {
  self.as_charset_converter().get_use_fallback()
}

///|
impl ICharsetConverter with fn set_use_fallback(self, use_fallback) -> Unit {
  self.as_charset_converter().set_use_fallback(use_fallback)
}

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

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

///|
pub fn CharsetConverter::as_converter(self : CharsetConverter) -> Converter = "%identity"

///|
pub impl IConverter for CharsetConverter with fn as_converter(self) {
  self.as_converter()
}

///|
pub fn CharsetConverter::as_initable(self : CharsetConverter) -> Initable = "%identity"

///|
pub impl IInitable for CharsetConverter with fn as_initable(self) {
  self.as_initable()
}