// GENERATED — DO NOT EDIT
///|
/// [Upstream documentation](https://docs.gtk.org/gio/class.SocketConnection.html).
pub type SocketConnection
///|
pub(open) trait ISocketConnection {
fn as_socket_connection(Self) -> SocketConnection
fn connect(Self, &ISocketAddress, &ICancellable?) -> Bool raise @glib.Error_ = _
fn get_local_address(Self) -> SocketAddress raise @glib.Error_ = _
fn get_remote_address(Self) -> SocketAddress raise @glib.Error_ = _
fn get_socket(Self) -> Socket = _
fn is_connected(Self) -> Bool = _
fn connect_async(
Self,
&ISocketAddress,
&ICancellable?,
(Result[Bool, @glib.Error_]) -> Unit,
) -> Unit = _
}
///|
pub impl ISocketConnection for SocketConnection with fn as_socket_connection(
self,
) {
self
}
///|
#borrow(self_, address, cancellable, error)
extern "c" fn moonbit_g_socket_connection_connect(
self_ : SocketConnection,
address : SocketAddress,
cancellable : @glib.Nullable[Cancellable],
error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_g_socket_connection_connect"
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SocketConnection.connect.html).
pub fn SocketConnection::connect(
self : SocketConnection,
address : &ISocketAddress,
cancellable : &ICancellable?,
) -> Bool raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_g_socket_connection_connect(
self,
address.as_socket_address(),
match cancellable {
Some(v) => @glib.Nullable::some(v.as_cancellable())
None => @glib.Nullable::null()
},
error_,
)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
#borrow(self_, error)
extern "c" fn moonbit_g_socket_connection_get_local_address(
self_ : SocketConnection,
error : Ref[@glib.Nullable[@glib.Error_]],
) -> SocketAddress = "moonbit_g_socket_connection_get_local_address"
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SocketConnection.get_local_address.html).
pub fn SocketConnection::get_local_address(
self : SocketConnection,
) -> SocketAddress raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_g_socket_connection_get_local_address(self, error_)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
#borrow(self_, error)
extern "c" fn moonbit_g_socket_connection_get_remote_address(
self_ : SocketConnection,
error : Ref[@glib.Nullable[@glib.Error_]],
) -> SocketAddress = "moonbit_g_socket_connection_get_remote_address"
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SocketConnection.get_remote_address.html).
pub fn SocketConnection::get_remote_address(
self : SocketConnection,
) -> SocketAddress raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_g_socket_connection_get_remote_address(self, error_)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SocketConnection.get_socket.html).
#borrow(self)
pub extern "c" fn SocketConnection::get_socket(
self : SocketConnection,
) -> Socket = "moonbit_g_socket_connection_get_socket"
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SocketConnection.is_connected.html).
#borrow(self)
pub extern "c" fn SocketConnection::is_connected(
self : SocketConnection,
) -> Bool = "moonbit_g_socket_connection_is_connected"
///|
#borrow(self_, address, cancellable)
extern "c" fn g_socket_connection_connect_async(
self_ : SocketConnection,
address : SocketAddress,
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_socket_connection_connect_async"
///|
/// [Upstream documentation](https://docs.gtk.org/gio/method.SocketConnection.connect_async.html).
pub fn SocketConnection::connect_async(
self : SocketConnection,
address : &ISocketAddress,
cancellable : &ICancellable?,
callback : (Result[Bool, @glib.Error_]) -> Unit,
) -> Unit {
g_socket_connection_connect_async(
self,
address.as_socket_address(),
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 ISocketConnection with fn connect(self, address, cancellable) -> Bool raise @glib.Error_ {
self.as_socket_connection().connect(address, cancellable)
}
///|
impl ISocketConnection with fn get_local_address(self) -> SocketAddress raise @glib.Error_ {
self.as_socket_connection().get_local_address()
}
///|
impl ISocketConnection with fn get_remote_address(self) -> SocketAddress raise @glib.Error_ {
self.as_socket_connection().get_remote_address()
}
///|
impl ISocketConnection with fn get_socket(self) -> Socket {
self.as_socket_connection().get_socket()
}
///|
impl ISocketConnection with fn is_connected(self) -> Bool {
self.as_socket_connection().is_connected()
}
///|
impl ISocketConnection with fn connect_async(
self,
address,
cancellable,
callback,
) -> Unit {
self.as_socket_connection().connect_async(address, cancellable, callback)
}
///|
pub fn SocketConnection::as_io_stream(self : SocketConnection) -> IOStream = "%identity"
///|
pub impl IIOStream for SocketConnection with fn as_io_stream(self) {
self.as_io_stream()
}
///|
pub fn SocketConnection::as_gobject_object(
self : SocketConnection,
) -> @gobject.Object = "%identity"
///|
pub impl @gobject.IObject for SocketConnection with fn as_object(self) {
self.as_gobject_object()
}