// GENERATED — DO NOT EDIT

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

///|
pub(open) trait ITlsClientConnection {
  fn as_tls_client_connection(Self) -> TlsClientConnection
  fn copy_session_state(Self, &ITlsClientConnection) -> Unit = _
  fn get_server_identity(Self) -> SocketConnectable? = _
  fn set_server_identity(Self, &ISocketConnectable) -> Unit = _
}

///|
pub impl ITlsClientConnection for TlsClientConnection with fn as_tls_client_connection(
  self,
) {
  self
}

///|
/// Implementation contract for TlsClientConnection.copy_session_state. Self is the retained MoonBit state; the second parameter is the invoked TlsClientConnection object.
pub(open) trait VTlsClientConnectionCopySessionState {
  fn copy_session_state(Self, TlsClientConnection, &ITlsClientConnection) -> Unit
}

///|
#borrow(base_io_stream, server_identity, error)
extern "c" fn moonbit_g_tls_client_connection_new(
  base_io_stream : IOStream,
  server_identity : @glib.Nullable[SocketConnectable],
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> TlsClientConnection = "moonbit_g_tls_client_connection_new"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/type_func.TlsClientConnection.new.html).
pub fn TlsClientConnection::new(
  base_io_stream : &IIOStream,
  server_identity : &ISocketConnectable?,
) -> TlsClientConnection raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let result = moonbit_g_tls_client_connection_new(
    base_io_stream.as_io_stream(),
    match server_identity {
      Some(v) => @glib.Nullable::some(v.as_socket_connectable())
      None => @glib.Nullable::null()
    },
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => result
  }
}

///|
#borrow(self_, source)
extern "c" fn moonbit_g_tls_client_connection_copy_session_state(
  self_ : TlsClientConnection,
  source : TlsClientConnection,
) = "moonbit_g_tls_client_connection_copy_session_state"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.TlsClientConnection.copy_session_state.html).
pub fn TlsClientConnection::copy_session_state(
  self : TlsClientConnection,
  source : &ITlsClientConnection,
) -> Unit {
  moonbit_g_tls_client_connection_copy_session_state(
    self,
    source.as_tls_client_connection(),
  )
}

///|
#borrow(self_)
extern "c" fn moonbit_g_tls_client_connection_get_server_identity(
  self_ : TlsClientConnection,
) -> @glib.Nullable[SocketConnectable] = "moonbit_g_tls_client_connection_get_server_identity"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.TlsClientConnection.get_server_identity.html).
pub fn TlsClientConnection::get_server_identity(
  self : TlsClientConnection,
) -> SocketConnectable? {
  let raw_result = moonbit_g_tls_client_connection_get_server_identity(self)
  raw_result.to_option()
}

///|
#borrow(self_, identity)
extern "c" fn moonbit_g_tls_client_connection_set_server_identity(
  self_ : TlsClientConnection,
  identity : SocketConnectable,
) = "moonbit_g_tls_client_connection_set_server_identity"

///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.TlsClientConnection.set_server_identity.html).
pub fn TlsClientConnection::set_server_identity(
  self : TlsClientConnection,
  identity : &ISocketConnectable,
) -> Unit {
  moonbit_g_tls_client_connection_set_server_identity(
    self,
    identity.as_socket_connectable(),
  )
}

///|
impl ITlsClientConnection with fn copy_session_state(self, source) -> Unit {
  self.as_tls_client_connection().copy_session_state(source)
}

///|
impl ITlsClientConnection with fn get_server_identity(self) -> SocketConnectable? {
  self.as_tls_client_connection().get_server_identity()
}

///|
impl ITlsClientConnection with fn set_server_identity(self, identity) -> Unit {
  self.as_tls_client_connection().set_server_identity(identity)
}

///|
pub fn TlsClientConnection::as_tls_connection(
  self : TlsClientConnection,
) -> TlsConnection = "%identity"

///|
pub impl ITlsConnection for TlsClientConnection with fn as_tls_connection(self) {
  self.as_tls_connection()
}