// GENERATED — DO NOT EDIT
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/class.Server.html).
pub type Server
///|
pub(open) trait IServer {
fn as_server(Self) -> Server
fn accept_iostream(
Self,
&@gio.IIOStream,
&@gio.ISocketAddress?,
&@gio.ISocketAddress?,
) -> Bool raise @glib.Error_ = _
fn disconnect(Self) -> Unit = _
fn get_tls_auth_mode(Self) -> @gio.TlsAuthenticationMode = _
fn get_tls_certificate(Self) -> @gio.TlsCertificate? = _
fn get_tls_database(Self) -> @gio.TlsDatabase? = _
fn get_uris(Self) -> Array[@glib.Uri] = _
fn is_https(Self) -> Bool = _
fn listen(Self, &@gio.ISocketAddress, ServerListenOptions) -> Bool raise @glib.Error_ = _
fn listen_all(Self, UInt, ServerListenOptions) -> Bool raise @glib.Error_ = _
fn listen_local(Self, UInt, ServerListenOptions) -> Bool raise @glib.Error_ = _
fn remove_handler(Self, String) -> Unit = _
fn set_tls_auth_mode(Self, @gio.TlsAuthenticationMode) -> Unit = _
fn set_tls_certificate(Self, &@gio.ITlsCertificate) -> Unit = _
fn set_tls_database(Self, &@gio.ITlsDatabase) -> Unit = _
fn connect_request_aborted(Self, (Server, ServerMessage) -> Unit) -> UInt64 = _
fn connect_request_finished(Self, (Server, ServerMessage) -> Unit) -> UInt64 = _
fn connect_request_read(Self, (Server, ServerMessage) -> Unit) -> UInt64 = _
fn connect_request_started(Self, (Server, ServerMessage) -> Unit) -> UInt64 = _
fn add_early_handler(
Self,
String?,
(Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit = _
fn add_handler(
Self,
String?,
(Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit = _
fn add_websocket_handler(
Self,
String?,
String?,
Array[String]?,
(Server, ServerMessage, String, WebsocketConnection) -> Unit,
) -> Unit = _
}
///|
pub impl IServer for Server with fn as_server(self) {
self
}
///|
/// Implementation contract for Server.request_aborted. Self is the retained MoonBit state; the second parameter is the invoked Server object.
pub(open) trait VServerRequestAborted {
fn request_aborted(Self, Server, &IServerMessage) -> Unit
}
///|
/// Implementation contract for Server.request_finished. Self is the retained MoonBit state; the second parameter is the invoked Server object.
pub(open) trait VServerRequestFinished {
fn request_finished(Self, Server, &IServerMessage) -> Unit
}
///|
/// Implementation contract for Server.request_read. Self is the retained MoonBit state; the second parameter is the invoked Server object.
pub(open) trait VServerRequestRead {
fn request_read(Self, Server, &IServerMessage) -> Unit
}
///|
/// Implementation contract for Server.request_started. Self is the retained MoonBit state; the second parameter is the invoked Server object.
pub(open) trait VServerRequestStarted {
fn request_started(Self, Server, &IServerMessage) -> Unit
}
///|
#borrow(self_, stream, local_addr, remote_addr, error)
extern "c" fn moonbit_soup_server_accept_iostream(
self_ : Server,
stream : @gio.IOStream,
local_addr : @glib.Nullable[@gio.SocketAddress],
remote_addr : @glib.Nullable[@gio.SocketAddress],
error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_soup_server_accept_iostream"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.accept_iostream.html).
pub fn Server::accept_iostream(
self : Server,
stream : &@gio.IIOStream,
local_addr : &@gio.ISocketAddress?,
remote_addr : &@gio.ISocketAddress?,
) -> Bool raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_soup_server_accept_iostream(
self,
stream.as_io_stream(),
match local_addr {
Some(v) => @glib.Nullable::some(v.as_socket_address())
None => @glib.Nullable::null()
},
match remote_addr {
Some(v) => @glib.Nullable::some(v.as_socket_address())
None => @glib.Nullable::null()
},
error_,
)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.disconnect.html).
#borrow(self)
pub extern "c" fn Server::disconnect(self : Server) = "moonbit_soup_server_disconnect"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.get_tls_auth_mode.html).
#borrow(self)
pub extern "c" fn Server::get_tls_auth_mode(
self : Server,
) -> @gio.TlsAuthenticationMode = "moonbit_soup_server_get_tls_auth_mode"
///|
#borrow(self_)
extern "c" fn moonbit_soup_server_get_tls_certificate(
self_ : Server,
) -> @glib.Nullable[@gio.TlsCertificate] = "moonbit_soup_server_get_tls_certificate"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.get_tls_certificate.html).
pub fn Server::get_tls_certificate(self : Server) -> @gio.TlsCertificate? {
let raw_result = moonbit_soup_server_get_tls_certificate(self)
raw_result.to_option()
}
///|
#borrow(self_)
extern "c" fn moonbit_soup_server_get_tls_database(
self_ : Server,
) -> @glib.Nullable[@gio.TlsDatabase] = "moonbit_soup_server_get_tls_database"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.get_tls_database.html).
pub fn Server::get_tls_database(self : Server) -> @gio.TlsDatabase? {
let raw_result = moonbit_soup_server_get_tls_database(self)
raw_result.to_option()
}
///|
#borrow(self_, result)
extern "c" fn moonbit_soup_server_get_uris(
self_ : Server,
result : Ref[FixedArray[@glib.Uri]],
) = "moonbit_soup_server_get_uris"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.get_uris.html).
pub fn Server::get_uris(self : Server) -> Array[@glib.Uri] {
let result_ref : Ref[FixedArray[@glib.Uri]] = Ref([])
moonbit_soup_server_get_uris(self, result_ref)
let values : Array[@glib.Uri] = Array::new(capacity=result_ref.val.length())
for value in result_ref.val {
values.push(value)
}
values
}
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.is_https.html).
#borrow(self)
pub extern "c" fn Server::is_https(self : Server) -> Bool = "moonbit_soup_server_is_https"
///|
#borrow(self_, address, error)
extern "c" fn moonbit_soup_server_listen(
self_ : Server,
address : @gio.SocketAddress,
options : Int,
error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_soup_server_listen"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.listen.html).
pub fn Server::listen(
self : Server,
address : &@gio.ISocketAddress,
options : ServerListenOptions,
) -> Bool raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_soup_server_listen(
self,
address.as_socket_address(),
options.to_int(),
error_,
)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
#borrow(self_, error)
extern "c" fn moonbit_soup_server_listen_all(
self_ : Server,
port : UInt,
options : Int,
error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_soup_server_listen_all"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.listen_all.html).
pub fn Server::listen_all(
self : Server,
port : UInt,
options : ServerListenOptions,
) -> Bool raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_soup_server_listen_all(
self,
port,
options.to_int(),
error_,
)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
#borrow(self_, error)
extern "c" fn moonbit_soup_server_listen_local(
self_ : Server,
port : UInt,
options : Int,
error : Ref[@glib.Nullable[@glib.Error_]],
) -> Bool = "moonbit_soup_server_listen_local"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.listen_local.html).
pub fn Server::listen_local(
self : Server,
port : UInt,
options : ServerListenOptions,
) -> Bool raise @glib.Error_ {
let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
let result = moonbit_soup_server_listen_local(
self,
port,
options.to_int(),
error_,
)
match error_.val.to_option() {
Some(e) => raise e
None => ()
}
result
}
///|
#borrow(self_, path)
extern "c" fn moonbit_soup_server_remove_handler(self_ : Server, path : Bytes) = "moonbit_soup_server_remove_handler"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.remove_handler.html).
pub fn Server::remove_handler(self : Server, path : String) -> Unit {
moonbit_soup_server_remove_handler(self, @encoding/utf8.encode(path))
}
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.set_tls_auth_mode.html).
#borrow(self)
pub extern "c" fn Server::set_tls_auth_mode(
self : Server,
mode : @gio.TlsAuthenticationMode,
) = "moonbit_soup_server_set_tls_auth_mode"
///|
#borrow(self_, certificate)
extern "c" fn moonbit_soup_server_set_tls_certificate(
self_ : Server,
certificate : @gio.TlsCertificate,
) = "moonbit_soup_server_set_tls_certificate"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.set_tls_certificate.html).
pub fn Server::set_tls_certificate(
self : Server,
certificate : &@gio.ITlsCertificate,
) -> Unit {
moonbit_soup_server_set_tls_certificate(
self,
certificate.as_tls_certificate(),
)
}
///|
#borrow(self_, tls_database)
extern "c" fn moonbit_soup_server_set_tls_database(
self_ : Server,
tls_database : @gio.TlsDatabase,
) = "moonbit_soup_server_set_tls_database"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.set_tls_database.html).
pub fn Server::set_tls_database(
self : Server,
tls_database : &@gio.ITlsDatabase,
) -> Unit {
moonbit_soup_server_set_tls_database(self, tls_database.as_tls_database())
}
///|
/// Creates a new Server with default property values.
pub extern "c" fn Server::new() -> Server = "moonbit_soup_server_new"
///|
#borrow(instance)
extern "c" fn soup_server_connect_request_aborted(
instance : Server,
function : FuncRef[
(Server, ServerMessage, (Server, ServerMessage) -> Unit) -> Unit,
],
closure : (Server, ServerMessage) -> Unit,
) -> UInt64 = "moonbit_soup_server_connect_request_aborted"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.Server.request-aborted.html).
pub fn Server::connect_request_aborted(
self : Server,
f : (Server, ServerMessage) -> Unit,
) -> UInt64 {
soup_server_connect_request_aborted(
self,
fn(instance_, message, f) { f(instance_, message) },
f,
)
}
///|
#borrow(instance)
extern "c" fn soup_server_connect_request_finished(
instance : Server,
function : FuncRef[
(Server, ServerMessage, (Server, ServerMessage) -> Unit) -> Unit,
],
closure : (Server, ServerMessage) -> Unit,
) -> UInt64 = "moonbit_soup_server_connect_request_finished"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.Server.request-finished.html).
pub fn Server::connect_request_finished(
self : Server,
f : (Server, ServerMessage) -> Unit,
) -> UInt64 {
soup_server_connect_request_finished(
self,
fn(instance_, message, f) { f(instance_, message) },
f,
)
}
///|
#borrow(instance)
extern "c" fn soup_server_connect_request_read(
instance : Server,
function : FuncRef[
(Server, ServerMessage, (Server, ServerMessage) -> Unit) -> Unit,
],
closure : (Server, ServerMessage) -> Unit,
) -> UInt64 = "moonbit_soup_server_connect_request_read"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.Server.request-read.html).
pub fn Server::connect_request_read(
self : Server,
f : (Server, ServerMessage) -> Unit,
) -> UInt64 {
soup_server_connect_request_read(
self,
fn(instance_, message, f) { f(instance_, message) },
f,
)
}
///|
#borrow(instance)
extern "c" fn soup_server_connect_request_started(
instance : Server,
function : FuncRef[
(Server, ServerMessage, (Server, ServerMessage) -> Unit) -> Unit,
],
closure : (Server, ServerMessage) -> Unit,
) -> UInt64 = "moonbit_soup_server_connect_request_started"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.Server.request-started.html).
pub fn Server::connect_request_started(
self : Server,
f : (Server, ServerMessage) -> Unit,
) -> UInt64 {
soup_server_connect_request_started(
self,
fn(instance_, message, f) { f(instance_, message) },
f,
)
}
///|
#borrow(instance, path)
extern "c" fn soup_server_add_early_handler(
instance : Server,
path : @glib.Nullable[Bytes],
function : FuncRef[
(
Server,
ServerMessage,
Bytes,
@glib.Nullable[@glib.HashTable],
(Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit,
],
closure : (Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit = "moonbit_soup_server_add_early_handler"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.add_early_handler.html).
pub fn Server::add_early_handler(
self : Server,
path : String?,
callback : (Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit {
soup_server_add_early_handler(
self,
match path {
Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
None => @glib.Nullable::null()
},
fn(server, msg, path, query, f) {
f(
server,
msg,
@encoding/utf8.decode_lossy(path),
if query.to_option() is Some(table) {
let m : Map[String, String] = Map([])
let it = table.iter()
while it.next() {
m[@encoding/utf8.decode_lossy(it.key_bytes())] = @encoding/utf8.decode_lossy(
it.val_bytes(),
)
}
Some(m)
} else {
None
},
)
},
callback,
)
}
///|
#borrow(instance, path)
extern "c" fn soup_server_add_handler(
instance : Server,
path : @glib.Nullable[Bytes],
function : FuncRef[
(
Server,
ServerMessage,
Bytes,
@glib.Nullable[@glib.HashTable],
(Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit,
],
closure : (Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit = "moonbit_soup_server_add_handler"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.add_handler.html).
pub fn Server::add_handler(
self : Server,
path : String?,
callback : (Server, ServerMessage, String, Map[String, String]?) -> Unit,
) -> Unit {
soup_server_add_handler(
self,
match path {
Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
None => @glib.Nullable::null()
},
fn(server, msg, path, query, f) {
f(
server,
msg,
@encoding/utf8.decode_lossy(path),
if query.to_option() is Some(table) {
let m : Map[String, String] = Map([])
let it = table.iter()
while it.next() {
m[@encoding/utf8.decode_lossy(it.key_bytes())] = @encoding/utf8.decode_lossy(
it.val_bytes(),
)
}
Some(m)
} else {
None
},
)
},
callback,
)
}
///|
#borrow(instance, path, origin, __sa_protocols)
extern "c" fn soup_server_add_websocket_handler(
instance : Server,
path : @glib.Nullable[Bytes],
origin : @glib.Nullable[Bytes],
__sa_protocols : @glib.Nullable[FixedArray[Bytes]],
function : FuncRef[
(
Server,
ServerMessage,
Bytes,
WebsocketConnection,
(Server, ServerMessage, String, WebsocketConnection) -> Unit,
) -> Unit,
],
closure : (Server, ServerMessage, String, WebsocketConnection) -> Unit,
) -> Unit = "moonbit_soup_server_add_websocket_handler"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.Server.add_websocket_handler.html).
pub fn Server::add_websocket_handler(
self : Server,
path : String?,
origin : String?,
protocols : Array[String]?,
callback : (Server, ServerMessage, String, WebsocketConnection) -> Unit,
) -> Unit {
soup_server_add_websocket_handler(
self,
match path {
Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
None => @glib.Nullable::null()
},
match origin {
Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
None => @glib.Nullable::null()
},
match protocols {
Some(arr) =>
@glib.Nullable::some(
FixedArray::from_array(arr.map(fn(s) { @encoding/utf8.encode(s) })),
)
None => @glib.Nullable::null()
},
fn(server, msg, path, connection, f) {
f(server, msg, @encoding/utf8.decode_lossy(path), connection)
},
callback,
)
}
///|
#borrow(self_)
extern "c" fn moonbit_soup_server_get_raw_paths(self_ : Server) -> Int = "moonbit_soup_server_get_raw_paths"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/property.Server.raw-paths.html).
pub fn Server::get_raw_paths(self : Server) -> Bool {
moonbit_soup_server_get_raw_paths(self) != 0
}
///|
#borrow(self_)
extern "c" fn moonbit_soup_server_get_server_header(self_ : Server) -> Bytes = "moonbit_soup_server_get_server_header"
///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/property.Server.server-header.html).
pub fn Server::get_server_header(self : Server) -> String {
@encoding/utf8.decode_lossy(moonbit_soup_server_get_server_header(self))
}
///|
#borrow(self_, value)
extern "c" fn moonbit_soup_server_set_server_header(
self_ : Server,
value : Bytes,
) = "moonbit_soup_server_set_server_header"
///|
pub fn Server::set_server_header(self : Server, value : String) -> Unit {
moonbit_soup_server_set_server_header(self, @encoding/utf8.encode(value))
}
///|
impl IServer with fn accept_iostream(self, stream, local_addr, remote_addr) -> Bool raise @glib.Error_ {
self.as_server().accept_iostream(stream, local_addr, remote_addr)
}
///|
impl IServer with fn disconnect(self) -> Unit {
self.as_server().disconnect()
}
///|
impl IServer with fn get_tls_auth_mode(self) -> @gio.TlsAuthenticationMode {
self.as_server().get_tls_auth_mode()
}
///|
impl IServer with fn get_tls_certificate(self) -> @gio.TlsCertificate? {
self.as_server().get_tls_certificate()
}
///|
impl IServer with fn get_tls_database(self) -> @gio.TlsDatabase? {
self.as_server().get_tls_database()
}
///|
impl IServer with fn get_uris(self) -> Array[@glib.Uri] {
self.as_server().get_uris()
}
///|
impl IServer with fn is_https(self) -> Bool {
self.as_server().is_https()
}
///|
impl IServer with fn listen(self, address, options) -> Bool raise @glib.Error_ {
self.as_server().listen(address, options)
}
///|
impl IServer with fn listen_all(self, port, options) -> Bool raise @glib.Error_ {
self.as_server().listen_all(port, options)
}
///|
impl IServer with fn listen_local(self, port, options) -> Bool raise @glib.Error_ {
self.as_server().listen_local(port, options)
}
///|
impl IServer with fn remove_handler(self, path) -> Unit {
self.as_server().remove_handler(path)
}
///|
impl IServer with fn set_tls_auth_mode(self, mode) -> Unit {
self.as_server().set_tls_auth_mode(mode)
}
///|
impl IServer with fn set_tls_certificate(self, certificate) -> Unit {
self.as_server().set_tls_certificate(certificate)
}
///|
impl IServer with fn set_tls_database(self, tls_database) -> Unit {
self.as_server().set_tls_database(tls_database)
}
///|
impl IServer with fn connect_request_aborted(self, f) -> UInt64 {
self.as_server().connect_request_aborted(f)
}
///|
impl IServer with fn connect_request_finished(self, f) -> UInt64 {
self.as_server().connect_request_finished(f)
}
///|
impl IServer with fn connect_request_read(self, f) -> UInt64 {
self.as_server().connect_request_read(f)
}
///|
impl IServer with fn connect_request_started(self, f) -> UInt64 {
self.as_server().connect_request_started(f)
}
///|
impl IServer with fn add_early_handler(self, path, callback) -> Unit {
self.as_server().add_early_handler(path, callback)
}
///|
impl IServer with fn add_handler(self, path, callback) -> Unit {
self.as_server().add_handler(path, callback)
}
///|
impl IServer with fn add_websocket_handler(
self,
path,
origin,
protocols,
callback,
) -> Unit {
self.as_server().add_websocket_handler(path, origin, protocols, callback)
}
///|
pub fn Server::as_gobject_object(self : Server) -> @gobject.Object = "%identity"
///|
pub impl @gobject.IObject for Server with fn as_object(self) {
self.as_gobject_object()
}