// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://docs.gtk.org/glib/struct.Uri.html).
pub type Uri

///|
pub(open) trait IUri {
  fn as_uri(Self) -> Uri
  fn get_auth_params(Self) -> String? = _
  fn get_flags(Self) -> UriFlags = _
  fn get_fragment(Self) -> String? = _
  fn get_host(Self) -> String? = _
  fn get_password(Self) -> String? = _
  fn get_path(Self) -> String = _
  fn get_port(Self) -> Int = _
  fn get_query(Self) -> String? = _
  fn get_scheme(Self) -> String = _
  fn get_user(Self) -> String? = _
  fn get_userinfo(Self) -> String? = _
  fn parse_relative(Self, String, UriFlags) -> Uri raise Error_ = _
  fn to_string(Self) -> String = _
  fn to_string_partial(Self, UriHideFlags) -> String = _
}

///|
pub impl IUri for Uri with fn as_uri(self) {
  self
}

///|
#borrow(scheme, userinfo, host, path, query, fragment)
extern "c" fn moonbit_g_uri_build(
  flags : Int,
  scheme : Bytes,
  userinfo : Nullable[Bytes],
  host : Nullable[Bytes],
  port : Int,
  path : Bytes,
  query : Nullable[Bytes],
  fragment : Nullable[Bytes],
) -> Uri = "moonbit_g_uri_build"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.build.html).
pub fn Uri::build(
  flags : UriFlags,
  scheme : String,
  userinfo : String?,
  host : String?,
  port : Int,
  path : String,
  query : String?,
  fragment : String?,
) -> Uri {
  moonbit_g_uri_build(
    flags.to_int(),
    @encoding/utf8.encode(scheme),
    match userinfo {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match host {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    port,
    @encoding/utf8.encode(path),
    match query {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match fragment {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
  )
}

///|
#borrow(scheme, user, password, auth_params, host, path, query, fragment)
extern "c" fn moonbit_g_uri_build_with_user(
  flags : Int,
  scheme : Bytes,
  user : Nullable[Bytes],
  password : Nullable[Bytes],
  auth_params : Nullable[Bytes],
  host : Nullable[Bytes],
  port : Int,
  path : Bytes,
  query : Nullable[Bytes],
  fragment : Nullable[Bytes],
) -> Uri = "moonbit_g_uri_build_with_user"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.build_with_user.html).
pub fn Uri::build_with_user(
  flags : UriFlags,
  scheme : String,
  user : String?,
  password : String?,
  auth_params : String?,
  host : String?,
  port : Int,
  path : String,
  query : String?,
  fragment : String?,
) -> Uri {
  moonbit_g_uri_build_with_user(
    flags.to_int(),
    @encoding/utf8.encode(scheme),
    match user {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match password {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match auth_params {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match host {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    port,
    @encoding/utf8.encode(path),
    match query {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match fragment {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
  )
}

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.error_quark.html).
pub extern "c" fn Uri::error_quark() -> UInt = "moonbit_g_uri_error_quark"

///|
#borrow(unescaped, reserved_chars_allowed)
extern "c" fn moonbit_g_uri_escape_string(
  unescaped : Bytes,
  reserved_chars_allowed : Nullable[Bytes],
  allow_utf8 : Bool,
) -> Bytes = "moonbit_g_uri_escape_string"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.escape_string.html).
pub fn Uri::escape_string(
  unescaped : String,
  reserved_chars_allowed : String?,
  allow_utf8 : Bool,
) -> String {
  @encoding/utf8.decode_lossy(
    moonbit_g_uri_escape_string(
      @encoding/utf8.encode(unescaped),
      match reserved_chars_allowed {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      allow_utf8,
    ),
  )
}

///|
#borrow(uri_string, error)
extern "c" fn moonbit_g_uri_is_valid(
  uri_string : Bytes,
  flags : Int,
  error : Ref[Nullable[Error_]],
) -> Bool = "moonbit_g_uri_is_valid"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.is_valid.html).
pub fn Uri::is_valid(
  uri_string : String,
  flags : UriFlags,
) -> Bool raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let result = moonbit_g_uri_is_valid(
    @encoding/utf8.encode(uri_string),
    flags.to_int(),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => result
  }
}

///|
#borrow(scheme, userinfo, host, path, query, fragment)
extern "c" fn moonbit_g_uri_join(
  flags : Int,
  scheme : Nullable[Bytes],
  userinfo : Nullable[Bytes],
  host : Nullable[Bytes],
  port : Int,
  path : Bytes,
  query : Nullable[Bytes],
  fragment : Nullable[Bytes],
) -> Bytes = "moonbit_g_uri_join"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.join.html).
pub fn Uri::join(
  flags : UriFlags,
  scheme : String?,
  userinfo : String?,
  host : String?,
  port : Int,
  path : String,
  query : String?,
  fragment : String?,
) -> String {
  @encoding/utf8.decode_lossy(
    moonbit_g_uri_join(
      flags.to_int(),
      match scheme {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match userinfo {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match host {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      port,
      @encoding/utf8.encode(path),
      match query {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match fragment {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
    ),
  )
}

///|
#borrow(scheme, user, password, auth_params, host, path, query, fragment)
extern "c" fn moonbit_g_uri_join_with_user(
  flags : Int,
  scheme : Nullable[Bytes],
  user : Nullable[Bytes],
  password : Nullable[Bytes],
  auth_params : Nullable[Bytes],
  host : Nullable[Bytes],
  port : Int,
  path : Bytes,
  query : Nullable[Bytes],
  fragment : Nullable[Bytes],
) -> Bytes = "moonbit_g_uri_join_with_user"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.join_with_user.html).
pub fn Uri::join_with_user(
  flags : UriFlags,
  scheme : String?,
  user : String?,
  password : String?,
  auth_params : String?,
  host : String?,
  port : Int,
  path : String,
  query : String?,
  fragment : String?,
) -> String {
  @encoding/utf8.decode_lossy(
    moonbit_g_uri_join_with_user(
      flags.to_int(),
      match scheme {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match user {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match password {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match auth_params {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match host {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      port,
      @encoding/utf8.encode(path),
      match query {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
      match fragment {
        Some(s) => Nullable::some(@encoding/utf8.encode(s))
        None => Nullable::null()
      },
    ),
  )
}

///|
#borrow(uri_string, error)
extern "c" fn moonbit_g_uri_parse(
  uri_string : Bytes,
  flags : Int,
  error : Ref[Nullable[Error_]],
) -> Uri = "moonbit_g_uri_parse"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.parse.html).
pub fn Uri::parse(uri_string : String, flags : UriFlags) -> Uri raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let result = moonbit_g_uri_parse(
    @encoding/utf8.encode(uri_string),
    flags.to_int(),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => result
  }
}

///|
#borrow(params, separators, error)
extern "c" fn moonbit_g_uri_parse_params(
  params : Bytes,
  length : Int64,
  separators : Bytes,
  flags : Int,
  error : Ref[Nullable[Error_]],
) -> HashTable = "moonbit_g_uri_parse_params"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.parse_params.html).
pub fn Uri::parse_params(
  params : String,
  length : Int64,
  separators : String,
  flags : UriParamsFlags,
) -> Map[String, String] raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let table = moonbit_g_uri_parse_params(
    @encoding/utf8.encode(params),
    length,
    @encoding/utf8.encode(separators),
    flags.to_int(),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  let map : Map[String, String] = Map([])
  let iter = table.iter()
  while iter.next() {
    map[@encoding/utf8.decode_lossy(iter.key_bytes())] = @encoding/utf8.decode_lossy(
      iter.val_bytes(),
    )
  }
  table.unref()
  map
}

///|
#borrow(uri)
extern "c" fn moonbit_g_uri_parse_scheme(uri : Bytes) -> Nullable[Bytes] = "moonbit_g_uri_parse_scheme"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.parse_scheme.html).
pub fn Uri::parse_scheme(uri : String) -> String? {
  let result = moonbit_g_uri_parse_scheme(@encoding/utf8.encode(uri))
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(uri)
extern "c" fn moonbit_g_uri_peek_scheme(uri : Bytes) -> Nullable[Bytes] = "moonbit_g_uri_peek_scheme"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.peek_scheme.html).
pub fn Uri::peek_scheme(uri : String) -> String? {
  let result = moonbit_g_uri_peek_scheme(@encoding/utf8.encode(uri))
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(base_uri_string, uri_ref, error)
extern "c" fn moonbit_g_uri_resolve_relative(
  base_uri_string : Nullable[Bytes],
  uri_ref : Bytes,
  flags : Int,
  error : Ref[Nullable[Error_]],
) -> Bytes = "moonbit_g_uri_resolve_relative"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.resolve_relative.html).
pub fn Uri::resolve_relative(
  base_uri_string : String?,
  uri_ref : String,
  flags : UriFlags,
) -> String raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let result_ = moonbit_g_uri_resolve_relative(
    match base_uri_string {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    @encoding/utf8.encode(uri_ref),
    flags.to_int(),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  @encoding/utf8.decode_lossy(result_)
}

///|
#borrow(uri_ref, scheme, userinfo, host, port, path, query, fragment, error)
extern "c" fn moonbit_g_uri_split(
  uri_ref : Bytes,
  flags : Int,
  scheme : Ref[Nullable[Bytes]],
  userinfo : Ref[Nullable[Bytes]],
  host : Ref[Nullable[Bytes]],
  port : Ref[Int],
  path : Ref[Nullable[Bytes]],
  query : Ref[Nullable[Bytes]],
  fragment : Ref[Nullable[Bytes]],
  error : Ref[Nullable[Error_]],
) -> Bool = "moonbit_g_uri_split"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.split.html).
pub fn Uri::split(
  uri_ref : String,
  flags : UriFlags,
) -> (String?, String?, String?, Int, String, String?, String?) raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let scheme : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let userinfo : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let host : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let port = Ref(0)
  let path : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let query : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let fragment : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  ignore(
    moonbit_g_uri_split(
      @encoding/utf8.encode(uri_ref),
      flags.to_int(),
      scheme,
      userinfo,
      host,
      port,
      path,
      query,
      fragment,
      error_,
    ),
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  (
    match scheme.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match userinfo.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match host.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    port.val,
    match path.val.to_option() {
      Some(bytes) => @encoding/utf8.decode_lossy(bytes)
      None => ""
    },
    match query.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match fragment.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
  )
}

///|
#borrow(uri_string, scheme, host, port, error)
extern "c" fn moonbit_g_uri_split_network(
  uri_string : Bytes,
  flags : Int,
  scheme : Ref[Nullable[Bytes]],
  host : Ref[Nullable[Bytes]],
  port : Ref[Int],
  error : Ref[Nullable[Error_]],
) -> Bool = "moonbit_g_uri_split_network"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.split_network.html).
pub fn Uri::split_network(
  uri_string : String,
  flags : UriFlags,
) -> (String?, String?, Int) raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let scheme : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let host : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let port = Ref(0)
  ignore(
    moonbit_g_uri_split_network(
      @encoding/utf8.encode(uri_string),
      flags.to_int(),
      scheme,
      host,
      port,
      error_,
    ),
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  (
    match scheme.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match host.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    port.val,
  )
}

///|
#borrow(uri_ref, scheme, user, password, auth_params, host, port, path, query, fragment, error)
extern "c" fn moonbit_g_uri_split_with_user(
  uri_ref : Bytes,
  flags : Int,
  scheme : Ref[Nullable[Bytes]],
  user : Ref[Nullable[Bytes]],
  password : Ref[Nullable[Bytes]],
  auth_params : Ref[Nullable[Bytes]],
  host : Ref[Nullable[Bytes]],
  port : Ref[Int],
  path : Ref[Nullable[Bytes]],
  query : Ref[Nullable[Bytes]],
  fragment : Ref[Nullable[Bytes]],
  error : Ref[Nullable[Error_]],
) -> Bool = "moonbit_g_uri_split_with_user"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.split_with_user.html).
pub fn Uri::split_with_user(
  uri_ref : String,
  flags : UriFlags,
) -> (
  String?,
  String?,
  String?,
  String?,
  String?,
  Int,
  String,
  String?,
  String?,
) raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let scheme : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let user : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let password : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let auth_params : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let host : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let port = Ref(0)
  let path : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let query : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  let fragment : Ref[Nullable[Bytes]] = Ref(Nullable::null())
  ignore(
    moonbit_g_uri_split_with_user(
      @encoding/utf8.encode(uri_ref),
      flags.to_int(),
      scheme,
      user,
      password,
      auth_params,
      host,
      port,
      path,
      query,
      fragment,
      error_,
    ),
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  (
    match scheme.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match user.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match password.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match auth_params.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match host.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    port.val,
    match path.val.to_option() {
      Some(bytes) => @encoding/utf8.decode_lossy(bytes)
      None => ""
    },
    match query.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
    match fragment.val.to_option() {
      Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
      None => None
    },
  )
}

///|
#borrow(escaped_string, illegal_characters, error)
extern "c" fn moonbit_g_uri_unescape_bytes(
  escaped_string : Bytes,
  length : Int64,
  illegal_characters : Nullable[Bytes],
  error : Ref[Nullable[Error_]],
) -> Bytes = "moonbit_g_uri_unescape_bytes"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.unescape_bytes.html).
pub fn Uri::unescape_bytes(
  escaped_string : String,
  length : Int64,
  illegal_characters : String?,
) -> Bytes raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let result = moonbit_g_uri_unescape_bytes(
    @encoding/utf8.encode(escaped_string),
    length,
    match illegal_characters {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => result
  }
}

///|
#borrow(escaped_string, escaped_string_end, illegal_characters)
extern "c" fn moonbit_g_uri_unescape_segment(
  escaped_string : Nullable[Bytes],
  escaped_string_end : Nullable[Bytes],
  illegal_characters : Nullable[Bytes],
) -> Nullable[Bytes] = "moonbit_g_uri_unescape_segment"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.unescape_segment.html).
pub fn Uri::unescape_segment(
  escaped_string : String?,
  escaped_string_end : String?,
  illegal_characters : String?,
) -> String? {
  let result = moonbit_g_uri_unescape_segment(
    match escaped_string {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match escaped_string_end {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
    match illegal_characters {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
  )
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(escaped_string, illegal_characters)
extern "c" fn moonbit_g_uri_unescape_string(
  escaped_string : Bytes,
  illegal_characters : Nullable[Bytes],
) -> Nullable[Bytes] = "moonbit_g_uri_unescape_string"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/type_func.Uri.unescape_string.html).
pub fn Uri::unescape_string(
  escaped_string : String,
  illegal_characters : String?,
) -> String? {
  let result = moonbit_g_uri_unescape_string(
    @encoding/utf8.encode(escaped_string),
    match illegal_characters {
      Some(s) => Nullable::some(@encoding/utf8.encode(s))
      None => Nullable::null()
    },
  )
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_auth_params(self_ : Uri) -> Nullable[Bytes] = "moonbit_g_uri_get_auth_params"

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

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_flags(self_ : Uri) -> Int = "moonbit_g_uri_get_flags"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/method.Uri.get_flags.html).
pub fn Uri::get_flags(self : Uri) -> UriFlags {
  UriFlags::from_int(moonbit_g_uri_get_flags(self))
}

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_fragment(self_ : Uri) -> Nullable[Bytes] = "moonbit_g_uri_get_fragment"

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

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_host(self_ : Uri) -> Nullable[Bytes] = "moonbit_g_uri_get_host"

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

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_password(self_ : Uri) -> Nullable[Bytes] = "moonbit_g_uri_get_password"

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

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

///|
/// [Upstream documentation](https://docs.gtk.org/glib/method.Uri.get_path.html).
pub fn Uri::get_path(self : Uri) -> String {
  @encoding/utf8.decode_lossy(moonbit_g_uri_get_path(self))
}

///|
/// [Upstream documentation](https://docs.gtk.org/glib/method.Uri.get_port.html).
#borrow(self)
pub extern "c" fn Uri::get_port(self : Uri) -> Int = "moonbit_g_uri_get_port"

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_query(self_ : Uri) -> Nullable[Bytes] = "moonbit_g_uri_get_query"

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

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

///|
/// [Upstream documentation](https://docs.gtk.org/glib/method.Uri.get_scheme.html).
pub fn Uri::get_scheme(self : Uri) -> String {
  @encoding/utf8.decode_lossy(moonbit_g_uri_get_scheme(self))
}

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_user(self_ : Uri) -> Nullable[Bytes] = "moonbit_g_uri_get_user"

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

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_get_userinfo(self_ : Uri) -> Nullable[Bytes] = "moonbit_g_uri_get_userinfo"

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

///|
#borrow(self_, uri_ref, error)
extern "c" fn moonbit_g_uri_parse_relative(
  self_ : Uri,
  uri_ref : Bytes,
  flags : Int,
  error : Ref[Nullable[Error_]],
) -> Uri = "moonbit_g_uri_parse_relative"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/method.Uri.parse_relative.html).
pub fn Uri::parse_relative(
  self : Uri,
  uri_ref : String,
  flags : UriFlags,
) -> Uri raise Error_ {
  let error_ : Ref[Nullable[Error_]] = Ref(Nullable::null())
  let result = moonbit_g_uri_parse_relative(
    self,
    @encoding/utf8.encode(uri_ref),
    flags.to_int(),
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  result
}

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

///|
/// [Upstream documentation](https://docs.gtk.org/glib/method.Uri.to_string.html).
pub fn Uri::to_string(self : Uri) -> String {
  @encoding/utf8.decode_lossy(moonbit_g_uri_to_string(self))
}

///|
#borrow(self_)
extern "c" fn moonbit_g_uri_to_string_partial(
  self_ : Uri,
  flags : Int,
) -> Bytes = "moonbit_g_uri_to_string_partial"

///|
/// [Upstream documentation](https://docs.gtk.org/glib/method.Uri.to_string_partial.html).
pub fn Uri::to_string_partial(self : Uri, flags : UriHideFlags) -> String {
  @encoding/utf8.decode_lossy(
    moonbit_g_uri_to_string_partial(self, flags.to_int()),
  )
}

///|
impl IUri with fn get_auth_params(self) -> String? {
  self.as_uri().get_auth_params()
}

///|
impl IUri with fn get_flags(self) -> UriFlags {
  self.as_uri().get_flags()
}

///|
impl IUri with fn get_fragment(self) -> String? {
  self.as_uri().get_fragment()
}

///|
impl IUri with fn get_host(self) -> String? {
  self.as_uri().get_host()
}

///|
impl IUri with fn get_password(self) -> String? {
  self.as_uri().get_password()
}

///|
impl IUri with fn get_path(self) -> String {
  self.as_uri().get_path()
}

///|
impl IUri with fn get_port(self) -> Int {
  self.as_uri().get_port()
}

///|
impl IUri with fn get_query(self) -> String? {
  self.as_uri().get_query()
}

///|
impl IUri with fn get_scheme(self) -> String {
  self.as_uri().get_scheme()
}

///|
impl IUri with fn get_user(self) -> String? {
  self.as_uri().get_user()
}

///|
impl IUri with fn get_userinfo(self) -> String? {
  self.as_uri().get_userinfo()
}

///|
impl IUri with fn parse_relative(self, uri_ref, flags) -> Uri raise Error_ {
  self.as_uri().parse_relative(uri_ref, flags)
}

///|
impl IUri with fn to_string(self) -> String {
  self.as_uri().to_string()
}

///|
impl IUri with fn to_string_partial(self, flags) -> String {
  self.as_uri().to_string_partial(flags)
}