// GENERATED — DO NOT EDIT

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

///|
pub(open) trait IProxyAddress {
  fn as_proxy_address(Self) -> ProxyAddress
  fn get_destination_hostname(Self) -> String = _
  fn get_destination_port(Self) -> UInt = _
  fn get_destination_protocol(Self) -> String = _
  fn get_password(Self) -> String? = _
  fn get_protocol(Self) -> String = _
  fn get_uri(Self) -> String? = _
  fn get_username(Self) -> String? = _
}

///|
pub impl IProxyAddress for ProxyAddress with fn as_proxy_address(self) {
  self
}

///|
#borrow(inetaddr, protocol, dest_hostname, username, password)
extern "c" fn moonbit_g_proxy_address_new(
  inetaddr : InetAddress,
  port : UInt,
  protocol : Bytes,
  dest_hostname : Bytes,
  dest_port : UInt,
  username : @glib.Nullable[Bytes],
  password : @glib.Nullable[Bytes],
) -> ProxyAddress = "moonbit_g_proxy_address_new"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/ctor.ProxyAddress.new.html).
pub fn ProxyAddress::new(
  inetaddr : &IInetAddress,
  port : UInt,
  protocol : String,
  dest_hostname : String,
  dest_port : UInt,
  username : String?,
  password : String?,
) -> ProxyAddress {
  moonbit_g_proxy_address_new(
    inetaddr.as_inet_address(),
    port,
    @encoding/utf8.encode(protocol),
    @encoding/utf8.encode(dest_hostname),
    dest_port,
    match username {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
    match password {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
  )
}

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

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

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

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

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

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

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

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

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

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

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

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

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

///|
impl IProxyAddress with fn get_destination_hostname(self) -> String {
  self.as_proxy_address().get_destination_hostname()
}

///|
impl IProxyAddress with fn get_destination_port(self) -> UInt {
  self.as_proxy_address().get_destination_port()
}

///|
impl IProxyAddress with fn get_destination_protocol(self) -> String {
  self.as_proxy_address().get_destination_protocol()
}

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

///|
impl IProxyAddress with fn get_protocol(self) -> String {
  self.as_proxy_address().get_protocol()
}

///|
impl IProxyAddress with fn get_uri(self) -> String? {
  self.as_proxy_address().get_uri()
}

///|
impl IProxyAddress with fn get_username(self) -> String? {
  self.as_proxy_address().get_username()
}

///|
pub fn ProxyAddress::as_inet_socket_address(
  self : ProxyAddress,
) -> InetSocketAddress = "%identity"

///|
pub impl IInetSocketAddress for ProxyAddress with fn as_inet_socket_address(
  self,
) {
  self.as_inet_socket_address()
}

///|
pub fn ProxyAddress::as_socket_address(self : ProxyAddress) -> SocketAddress = "%identity"

///|
pub impl ISocketAddress for ProxyAddress with fn as_socket_address(self) {
  self.as_socket_address()
}

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

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

///|
pub fn ProxyAddress::as_socket_connectable(
  self : ProxyAddress,
) -> SocketConnectable = "%identity"

///|
pub impl ISocketConnectable for ProxyAddress with fn as_socket_connectable(self) {
  self.as_socket_connectable()
}