From 059efb09c25f04a549a9d6b89c5812376df67e49 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 1 Dec 2024 13:06:13 +0100 Subject: [PATCH] Generate all the missing Gio bindings Only the ones that can be generated now without requiring any manual implementations. --- gio/Gir.toml | 37 + gio/src/auto/dbus_object_manager_server.rs | 124 +++ gio/src/auto/dbus_object_proxy.rs | 53 ++ gio/src/auto/dbus_object_skeleton.rs | 157 ++++ gio/src/auto/dtls_client_connection.rs | 187 +++++ gio/src/auto/dtls_connection.rs | 849 +++++++++++++++++++++ gio/src/auto/dtls_server_connection.rs | 84 ++ gio/src/auto/enums.rs | 701 +++++++++++++++++ gio/src/auto/flags.rs | 332 ++++++++ gio/src/auto/mod.rs | 68 ++ gio/src/auto/native_socket_address.rs | 23 + gio/src/auto/native_volume_monitor.rs | 18 + gio/src/auto/proxy_address_enumerator.rs | 77 ++ gio/src/auto/tcp_wrapper_connection.rs | 48 ++ gio/src/auto/test_dbus.rs | 69 ++ gio/src/auto/unix_connection.rs | 236 ++++++ gio/src/auto/unix_mount_monitor.rs | 71 ++ 17 files changed, 3134 insertions(+) create mode 100644 gio/src/auto/dbus_object_manager_server.rs create mode 100644 gio/src/auto/dbus_object_proxy.rs create mode 100644 gio/src/auto/dbus_object_skeleton.rs create mode 100644 gio/src/auto/dtls_client_connection.rs create mode 100644 gio/src/auto/dtls_connection.rs create mode 100644 gio/src/auto/dtls_server_connection.rs create mode 100644 gio/src/auto/native_socket_address.rs create mode 100644 gio/src/auto/native_volume_monitor.rs create mode 100644 gio/src/auto/proxy_address_enumerator.rs create mode 100644 gio/src/auto/tcp_wrapper_connection.rs create mode 100644 gio/src/auto/test_dbus.rs create mode 100644 gio/src/auto/unix_connection.rs create mode 100644 gio/src/auto/unix_mount_monitor.rs diff --git a/gio/Gir.toml b/gio/Gir.toml index 05c34f6f1a63..0fcf3cc6044f 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -29,6 +29,7 @@ generate = [ "Gio.DBusAuthObserver", "Gio.DBusCallFlags", "Gio.DBusCapabilityFlags", + "Gio.DBusError", "Gio.DBusInterfaceGetPropertyFunc", "Gio.DBusInterfaceMethodCallFunc", "Gio.DBusInterfaceSetPropertyFunc", @@ -45,16 +46,23 @@ generate = [ "Gio.DBusObject", "Gio.DBusObjectManager", "Gio.DBusObjectManagerClientFlags", + "Gio.DBusObjectManagerServer", + "Gio.DBusObjectProxy", + "Gio.DBusObjectSkeleton", "Gio.DBusPropertyInfo", + "Gio.DBusPropertyInfoFlags", "Gio.DBusSendMessageFlags", "Gio.DBusServer", "Gio.DBusServerFlags", "Gio.DBusSignalFlags", "Gio.DBusSignalInfo", + "Gio.DBusSubtreeFlags", "Gio.DebugController", "Gio.Drive", "Gio.DriveStartFlags", "Gio.DriveStartStopType", + "Gio.DtlsClientConnection", + "Gio.DtlsServerConnection", "Gio.Emblem", "Gio.EmblemedIcon", "Gio.EmblemOrigin", @@ -72,8 +80,10 @@ generate = [ "Gio.FilenameCompleter", "Gio.FileOutputStream", "Gio.FileQueryInfoFlags", + "Gio.FilesystemPreviewType", "Gio.FileType", "Gio.FilterInputStream", + "Gio.IOModuleScopeFlags", "Gio.IOStreamSpliceFlags", "Gio.LoadableIcon", "Gio.MemoryMonitor", @@ -85,6 +95,8 @@ generate = [ "Gio.MountOperation", "Gio.MountOperationResult", "Gio.MountUnmountFlags", + "Gio.NativeSocketAddress", + "Gio.NativeVolumeMonitor", "Gio.NetworkConnectivity", "Gio.NetworkMonitor", "Gio.NetworkService", @@ -96,11 +108,13 @@ generate = [ "Gio.PollableReturn", "Gio.PropertyAction", "Gio.Proxy", + "Gio.ProxyAddressEnumerator", "Gio.ProxyResolver", "Gio.RemoteActionGroup", "Gio.ResolverError", "Gio.ResolverNameLookupFlags", "Gio.ResourceError", + "Gio.ResourceFlags", "Gio.ResourceLookupFlags", "Gio.Seekable", "Gio.SettingsBackend", @@ -124,10 +138,14 @@ generate = [ "Gio.SocketType", "Gio.SrvTarget", "Gio.TcpConnection", + "Gio.TcpWrapperConnection", + "Gio.TestDBus", + "Gio.TestDBusFlags", "Gio.TlsAuthenticationMode", "Gio.TlsBackend", "Gio.TlsCertificate", "Gio.TlsCertificateRequestFlags", + "Gio.TlsChannelBindingError", "Gio.TlsClientConnection", "Gio.TlsDatabase", "Gio.TlsDatabaseLookupFlags", @@ -146,6 +164,7 @@ generate = [ ] ignore = [ + "Gio.ThreadedResolver", # Same as sys class, not sure if this needs to be exposed ] manual = [ @@ -155,6 +174,7 @@ manual = [ "Gio.IOExtension", "Gio.IOExtensionPoint", "Gio.OutputMessage", + "Gio.SocketMsgFlags", "Gio.Task", "GLib.ByteArray", "GLib.Bytes", @@ -708,6 +728,13 @@ cfg_condition = "all(not(windows),not(target_os = \"macos\"))" # has to use RawFd / SOCKET manual = true +[[object]] +name = "Gio.DtlsConnection" +status = "generate" + [[object.function]] + name = "get_channel_binding_data" + ignore = true # needs manual implementation + [[object]] name = "Gio.File" status = "generate" @@ -1480,6 +1507,11 @@ status = "generate" name = "set_value" ignore = true +[[object]] +name = "Gio.UnixConnection" +status = "generate" +cfg_condition = "unix" + [[object]] name = "Gio.UnixCredentialsMessage" status = "generate" @@ -1601,6 +1633,11 @@ cfg_condition = "unix" version = "2.0" rename = "for_file_path" +[[object]] +name = "Gio.UnixMountMonitor" +status = "generate" +cfg_condition = "unix" + [[object]] name = "Gio.UnixMountPoint" status = "generate" diff --git a/gio/src/auto/dbus_object_manager_server.rs b/gio/src/auto/dbus_object_manager_server.rs new file mode 100644 index 000000000000..ab67ab560dd5 --- /dev/null +++ b/gio/src/auto/dbus_object_manager_server.rs @@ -0,0 +1,124 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, DBusConnection, DBusObjectManager, DBusObjectSkeleton}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GDBusObjectManagerServer")] + pub struct DBusObjectManagerServer(Object) @implements DBusObjectManager; + + match fn { + type_ => || ffi::g_dbus_object_manager_server_get_type(), + } +} + +impl DBusObjectManagerServer { + pub const NONE: Option<&'static DBusObjectManagerServer> = None; + + #[doc(alias = "g_dbus_object_manager_server_new")] + pub fn new(object_path: &str) -> DBusObjectManagerServer { + unsafe { + from_glib_full(ffi::g_dbus_object_manager_server_new( + object_path.to_glib_none().0, + )) + } + } +} + +pub trait DBusObjectManagerServerExt: IsA + 'static { + #[doc(alias = "g_dbus_object_manager_server_export")] + fn export(&self, object: &impl IsA) { + unsafe { + ffi::g_dbus_object_manager_server_export( + self.as_ref().to_glib_none().0, + object.as_ref().to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dbus_object_manager_server_export_uniquely")] + fn export_uniquely(&self, object: &impl IsA) { + unsafe { + ffi::g_dbus_object_manager_server_export_uniquely( + self.as_ref().to_glib_none().0, + object.as_ref().to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dbus_object_manager_server_get_connection")] + #[doc(alias = "get_connection")] + fn connection(&self) -> Option { + unsafe { + from_glib_full(ffi::g_dbus_object_manager_server_get_connection( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dbus_object_manager_server_is_exported")] + fn is_exported(&self, object: &impl IsA) -> bool { + unsafe { + from_glib(ffi::g_dbus_object_manager_server_is_exported( + self.as_ref().to_glib_none().0, + object.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dbus_object_manager_server_set_connection")] + #[doc(alias = "connection")] + fn set_connection(&self, connection: Option<&DBusConnection>) { + unsafe { + ffi::g_dbus_object_manager_server_set_connection( + self.as_ref().to_glib_none().0, + connection.to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dbus_object_manager_server_unexport")] + fn unexport(&self, object_path: &str) -> bool { + unsafe { + from_glib(ffi::g_dbus_object_manager_server_unexport( + self.as_ref().to_glib_none().0, + object_path.to_glib_none().0, + )) + } + } + + #[doc(alias = "connection")] + fn connect_connection_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_connection_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDBusObjectManagerServer, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DBusObjectManagerServer::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::connection\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_connection_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> DBusObjectManagerServerExt for O {} diff --git a/gio/src/auto/dbus_object_proxy.rs b/gio/src/auto/dbus_object_proxy.rs new file mode 100644 index 000000000000..68599237101d --- /dev/null +++ b/gio/src/auto/dbus_object_proxy.rs @@ -0,0 +1,53 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, DBusConnection, DBusObject}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GDBusObjectProxy")] + pub struct DBusObjectProxy(Object) @implements DBusObject; + + match fn { + type_ => || ffi::g_dbus_object_proxy_get_type(), + } +} + +impl DBusObjectProxy { + pub const NONE: Option<&'static DBusObjectProxy> = None; + + #[doc(alias = "g_dbus_object_proxy_new")] + pub fn new(connection: &DBusConnection, object_path: &str) -> DBusObjectProxy { + unsafe { + from_glib_full(ffi::g_dbus_object_proxy_new( + connection.to_glib_none().0, + object_path.to_glib_none().0, + )) + } + } +} + +pub trait DBusObjectProxyExt: IsA + 'static { + #[doc(alias = "g_dbus_object_proxy_get_connection")] + #[doc(alias = "get_connection")] + fn connection(&self) -> DBusConnection { + unsafe { + from_glib_none(ffi::g_dbus_object_proxy_get_connection( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g-connection")] + fn g_connection(&self) -> Option { + ObjectExt::property(self.as_ref(), "g-connection") + } + + #[doc(alias = "g-object-path")] + fn g_object_path(&self) -> Option { + ObjectExt::property(self.as_ref(), "g-object-path") + } +} + +impl> DBusObjectProxyExt for O {} diff --git a/gio/src/auto/dbus_object_skeleton.rs b/gio/src/auto/dbus_object_skeleton.rs new file mode 100644 index 000000000000..5738bb2cae21 --- /dev/null +++ b/gio/src/auto/dbus_object_skeleton.rs @@ -0,0 +1,157 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, DBusInterfaceSkeleton, DBusMethodInvocation, DBusObject}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GDBusObjectSkeleton")] + pub struct DBusObjectSkeleton(Object) @implements DBusObject; + + match fn { + type_ => || ffi::g_dbus_object_skeleton_get_type(), + } +} + +impl DBusObjectSkeleton { + pub const NONE: Option<&'static DBusObjectSkeleton> = None; + + #[doc(alias = "g_dbus_object_skeleton_new")] + pub fn new(object_path: &str) -> DBusObjectSkeleton { + unsafe { + from_glib_full(ffi::g_dbus_object_skeleton_new( + object_path.to_glib_none().0, + )) + } + } +} + +pub trait DBusObjectSkeletonExt: IsA + 'static { + #[doc(alias = "g_dbus_object_skeleton_add_interface")] + fn add_interface(&self, interface_: &impl IsA) { + unsafe { + ffi::g_dbus_object_skeleton_add_interface( + self.as_ref().to_glib_none().0, + interface_.as_ref().to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dbus_object_skeleton_flush")] + fn flush(&self) { + unsafe { + ffi::g_dbus_object_skeleton_flush(self.as_ref().to_glib_none().0); + } + } + + #[doc(alias = "g_dbus_object_skeleton_remove_interface")] + fn remove_interface(&self, interface_: &impl IsA) { + unsafe { + ffi::g_dbus_object_skeleton_remove_interface( + self.as_ref().to_glib_none().0, + interface_.as_ref().to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dbus_object_skeleton_remove_interface_by_name")] + fn remove_interface_by_name(&self, interface_name: &str) { + unsafe { + ffi::g_dbus_object_skeleton_remove_interface_by_name( + self.as_ref().to_glib_none().0, + interface_name.to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dbus_object_skeleton_set_object_path")] + fn set_object_path(&self, object_path: &str) { + unsafe { + ffi::g_dbus_object_skeleton_set_object_path( + self.as_ref().to_glib_none().0, + object_path.to_glib_none().0, + ); + } + } + + #[doc(alias = "g-object-path")] + fn g_object_path(&self) -> Option { + ObjectExt::property(self.as_ref(), "g-object-path") + } + + #[doc(alias = "g-object-path")] + fn set_g_object_path(&self, g_object_path: Option<&str>) { + ObjectExt::set_property(self.as_ref(), "g-object-path", g_object_path) + } + + #[doc(alias = "authorize-method")] + fn connect_authorize_method< + F: Fn(&Self, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static, + >( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn authorize_method_trampoline< + P: IsA, + F: Fn(&P, &DBusInterfaceSkeleton, &DBusMethodInvocation) -> bool + 'static, + >( + this: *mut ffi::GDBusObjectSkeleton, + interface: *mut ffi::GDBusInterfaceSkeleton, + invocation: *mut ffi::GDBusMethodInvocation, + f: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { + let f: &F = &*(f as *const F); + f( + DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref(), + &from_glib_borrow(interface), + &from_glib_borrow(invocation), + ) + .into_glib() + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"authorize-method\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + authorize_method_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "g-object-path")] + fn connect_g_object_path_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_g_object_path_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDBusObjectSkeleton, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DBusObjectSkeleton::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::g-object-path\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_g_object_path_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> DBusObjectSkeletonExt for O {} diff --git a/gio/src/auto/dtls_client_connection.rs b/gio/src/auto/dtls_client_connection.rs new file mode 100644 index 000000000000..d57f50ddd7ed --- /dev/null +++ b/gio/src/auto/dtls_client_connection.rs @@ -0,0 +1,187 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT +#![allow(deprecated)] + +use crate::{ffi, DatagramBased, DtlsConnection, SocketConnectable, TlsCertificateFlags}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GDtlsClientConnection")] + pub struct DtlsClientConnection(Interface) @requires DatagramBased, DtlsConnection; + + match fn { + type_ => || ffi::g_dtls_client_connection_get_type(), + } +} + +impl DtlsClientConnection { + pub const NONE: Option<&'static DtlsClientConnection> = None; + + #[doc(alias = "g_dtls_client_connection_new")] + pub fn new( + base_socket: &impl IsA, + server_identity: Option<&impl IsA>, + ) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::g_dtls_client_connection_new( + base_socket.as_ref().to_glib_none().0, + server_identity.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } +} + +pub trait DtlsClientConnectionExt: IsA + 'static { + #[doc(alias = "g_dtls_client_connection_get_accepted_cas")] + #[doc(alias = "get_accepted_cas")] + #[doc(alias = "accepted-cas")] + fn accepted_cas(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::g_dtls_client_connection_get_accepted_cas( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_client_connection_get_server_identity")] + #[doc(alias = "get_server_identity")] + #[doc(alias = "server-identity")] + fn server_identity(&self) -> SocketConnectable { + unsafe { + from_glib_none(ffi::g_dtls_client_connection_get_server_identity( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg_attr(feature = "v2_74", deprecated = "Since 2.74")] + #[allow(deprecated)] + #[doc(alias = "g_dtls_client_connection_get_validation_flags")] + #[doc(alias = "get_validation_flags")] + #[doc(alias = "validation-flags")] + fn validation_flags(&self) -> TlsCertificateFlags { + unsafe { + from_glib(ffi::g_dtls_client_connection_get_validation_flags( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_client_connection_set_server_identity")] + #[doc(alias = "server-identity")] + fn set_server_identity(&self, identity: &impl IsA) { + unsafe { + ffi::g_dtls_client_connection_set_server_identity( + self.as_ref().to_glib_none().0, + identity.as_ref().to_glib_none().0, + ); + } + } + + #[cfg_attr(feature = "v2_74", deprecated = "Since 2.74")] + #[allow(deprecated)] + #[doc(alias = "g_dtls_client_connection_set_validation_flags")] + #[doc(alias = "validation-flags")] + fn set_validation_flags(&self, flags: TlsCertificateFlags) { + unsafe { + ffi::g_dtls_client_connection_set_validation_flags( + self.as_ref().to_glib_none().0, + flags.into_glib(), + ); + } + } + + #[doc(alias = "accepted-cas")] + fn connect_accepted_cas_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_accepted_cas_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsClientConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsClientConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::accepted-cas\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_accepted_cas_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "server-identity")] + fn connect_server_identity_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_server_identity_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsClientConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsClientConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::server-identity\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_server_identity_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[cfg_attr(feature = "v2_74", deprecated = "Since 2.74")] + #[doc(alias = "validation-flags")] + fn connect_validation_flags_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_validation_flags_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsClientConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsClientConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::validation-flags\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_validation_flags_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> DtlsClientConnectionExt for O {} diff --git a/gio/src/auto/dtls_connection.rs b/gio/src/auto/dtls_connection.rs new file mode 100644 index 000000000000..f4505d19e025 --- /dev/null +++ b/gio/src/auto/dtls_connection.rs @@ -0,0 +1,849 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT +#![allow(deprecated)] + +#[cfg(feature = "v2_70")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] +use crate::TlsProtocolVersion; +use crate::{ + ffi, AsyncResult, Cancellable, DatagramBased, TlsCertificate, TlsCertificateFlags, TlsDatabase, + TlsInteraction, TlsRehandshakeMode, +}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::{boxed::Box as Box_, pin::Pin}; + +glib::wrapper! { + #[doc(alias = "GDtlsConnection")] + pub struct DtlsConnection(Interface) @requires DatagramBased; + + match fn { + type_ => || ffi::g_dtls_connection_get_type(), + } +} + +impl DtlsConnection { + pub const NONE: Option<&'static DtlsConnection> = None; +} + +pub trait DtlsConnectionExt: IsA + 'static { + #[doc(alias = "g_dtls_connection_close")] + fn close(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::g_dtls_connection_close( + self.as_ref().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "g_dtls_connection_close_async")] + fn close_async) + 'static>( + &self, + io_priority: glib::Priority, + cancellable: Option<&impl IsA>, + callback: P, + ) { + let main_context = glib::MainContext::ref_thread_default(); + let is_main_context_owner = main_context.is_owner(); + let has_acquired_main_context = (!is_main_context_owner) + .then(|| main_context.acquire().ok()) + .flatten(); + assert!( + is_main_context_owner || has_acquired_main_context.is_some(), + "Async operations only allowed if the thread is owning the MainContext" + ); + + let user_data: Box_> = + Box_::new(glib::thread_guard::ThreadGuard::new(callback)); + unsafe extern "C" fn close_async_trampoline< + P: FnOnce(Result<(), glib::Error>) + 'static, + >( + _source_object: *mut glib::gobject_ffi::GObject, + res: *mut crate::ffi::GAsyncResult, + user_data: glib::ffi::gpointer, + ) { + let mut error = std::ptr::null_mut(); + let _ = ffi::g_dtls_connection_close_finish(_source_object as *mut _, res, &mut error); + let result = if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + }; + let callback: Box_> = + Box_::from_raw(user_data as *mut _); + let callback: P = callback.into_inner(); + callback(result); + } + let callback = close_async_trampoline::

; + unsafe { + ffi::g_dtls_connection_close_async( + self.as_ref().to_glib_none().0, + io_priority.into_glib(), + cancellable.map(|p| p.as_ref()).to_glib_none().0, + Some(callback), + Box_::into_raw(user_data) as *mut _, + ); + } + } + + fn close_future( + &self, + io_priority: glib::Priority, + ) -> Pin> + 'static>> { + Box_::pin(crate::GioFuture::new( + self, + move |obj, cancellable, send| { + obj.close_async(io_priority, Some(cancellable), move |res| { + send.resolve(res); + }); + }, + )) + } + + #[doc(alias = "g_dtls_connection_emit_accept_certificate")] + fn emit_accept_certificate( + &self, + peer_cert: &impl IsA, + errors: TlsCertificateFlags, + ) -> bool { + unsafe { + from_glib(ffi::g_dtls_connection_emit_accept_certificate( + self.as_ref().to_glib_none().0, + peer_cert.as_ref().to_glib_none().0, + errors.into_glib(), + )) + } + } + + #[doc(alias = "g_dtls_connection_get_certificate")] + #[doc(alias = "get_certificate")] + fn certificate(&self) -> Option { + unsafe { + from_glib_none(ffi::g_dtls_connection_get_certificate( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg(feature = "v2_70")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] + #[doc(alias = "g_dtls_connection_get_ciphersuite_name")] + #[doc(alias = "get_ciphersuite_name")] + #[doc(alias = "ciphersuite-name")] + fn ciphersuite_name(&self) -> Option { + unsafe { + from_glib_full(ffi::g_dtls_connection_get_ciphersuite_name( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_connection_get_database")] + #[doc(alias = "get_database")] + fn database(&self) -> Option { + unsafe { + from_glib_none(ffi::g_dtls_connection_get_database( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_connection_get_interaction")] + #[doc(alias = "get_interaction")] + fn interaction(&self) -> Option { + unsafe { + from_glib_none(ffi::g_dtls_connection_get_interaction( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + #[doc(alias = "g_dtls_connection_get_negotiated_protocol")] + #[doc(alias = "get_negotiated_protocol")] + #[doc(alias = "negotiated-protocol")] + fn negotiated_protocol(&self) -> Option { + unsafe { + from_glib_none(ffi::g_dtls_connection_get_negotiated_protocol( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_connection_get_peer_certificate")] + #[doc(alias = "get_peer_certificate")] + #[doc(alias = "peer-certificate")] + fn peer_certificate(&self) -> Option { + unsafe { + from_glib_none(ffi::g_dtls_connection_get_peer_certificate( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_connection_get_peer_certificate_errors")] + #[doc(alias = "get_peer_certificate_errors")] + #[doc(alias = "peer-certificate-errors")] + fn peer_certificate_errors(&self) -> TlsCertificateFlags { + unsafe { + from_glib(ffi::g_dtls_connection_get_peer_certificate_errors( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg(feature = "v2_70")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] + #[doc(alias = "g_dtls_connection_get_protocol_version")] + #[doc(alias = "get_protocol_version")] + #[doc(alias = "protocol-version")] + fn protocol_version(&self) -> TlsProtocolVersion { + unsafe { + from_glib(ffi::g_dtls_connection_get_protocol_version( + self.as_ref().to_glib_none().0, + )) + } + } + + #[cfg_attr(feature = "v2_64", deprecated = "Since 2.64")] + #[allow(deprecated)] + #[doc(alias = "g_dtls_connection_get_rehandshake_mode")] + #[doc(alias = "get_rehandshake_mode")] + #[doc(alias = "rehandshake-mode")] + fn rehandshake_mode(&self) -> TlsRehandshakeMode { + unsafe { + from_glib(ffi::g_dtls_connection_get_rehandshake_mode( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_connection_get_require_close_notify")] + #[doc(alias = "get_require_close_notify")] + #[doc(alias = "require-close-notify")] + fn requires_close_notify(&self) -> bool { + unsafe { + from_glib(ffi::g_dtls_connection_get_require_close_notify( + self.as_ref().to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dtls_connection_handshake")] + fn handshake(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::g_dtls_connection_handshake( + self.as_ref().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "g_dtls_connection_handshake_async")] + fn handshake_async) + 'static>( + &self, + io_priority: glib::Priority, + cancellable: Option<&impl IsA>, + callback: P, + ) { + let main_context = glib::MainContext::ref_thread_default(); + let is_main_context_owner = main_context.is_owner(); + let has_acquired_main_context = (!is_main_context_owner) + .then(|| main_context.acquire().ok()) + .flatten(); + assert!( + is_main_context_owner || has_acquired_main_context.is_some(), + "Async operations only allowed if the thread is owning the MainContext" + ); + + let user_data: Box_> = + Box_::new(glib::thread_guard::ThreadGuard::new(callback)); + unsafe extern "C" fn handshake_async_trampoline< + P: FnOnce(Result<(), glib::Error>) + 'static, + >( + _source_object: *mut glib::gobject_ffi::GObject, + res: *mut crate::ffi::GAsyncResult, + user_data: glib::ffi::gpointer, + ) { + let mut error = std::ptr::null_mut(); + let _ = + ffi::g_dtls_connection_handshake_finish(_source_object as *mut _, res, &mut error); + let result = if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + }; + let callback: Box_> = + Box_::from_raw(user_data as *mut _); + let callback: P = callback.into_inner(); + callback(result); + } + let callback = handshake_async_trampoline::

; + unsafe { + ffi::g_dtls_connection_handshake_async( + self.as_ref().to_glib_none().0, + io_priority.into_glib(), + cancellable.map(|p| p.as_ref()).to_glib_none().0, + Some(callback), + Box_::into_raw(user_data) as *mut _, + ); + } + } + + fn handshake_future( + &self, + io_priority: glib::Priority, + ) -> Pin> + 'static>> { + Box_::pin(crate::GioFuture::new( + self, + move |obj, cancellable, send| { + obj.handshake_async(io_priority, Some(cancellable), move |res| { + send.resolve(res); + }); + }, + )) + } + + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + #[doc(alias = "g_dtls_connection_set_advertised_protocols")] + #[doc(alias = "advertised-protocols")] + fn set_advertised_protocols(&self, protocols: &[&str]) { + unsafe { + ffi::g_dtls_connection_set_advertised_protocols( + self.as_ref().to_glib_none().0, + protocols.to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dtls_connection_set_certificate")] + #[doc(alias = "certificate")] + fn set_certificate(&self, certificate: &impl IsA) { + unsafe { + ffi::g_dtls_connection_set_certificate( + self.as_ref().to_glib_none().0, + certificate.as_ref().to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dtls_connection_set_database")] + #[doc(alias = "database")] + fn set_database(&self, database: Option<&impl IsA>) { + unsafe { + ffi::g_dtls_connection_set_database( + self.as_ref().to_glib_none().0, + database.map(|p| p.as_ref()).to_glib_none().0, + ); + } + } + + #[doc(alias = "g_dtls_connection_set_interaction")] + #[doc(alias = "interaction")] + fn set_interaction(&self, interaction: Option<&impl IsA>) { + unsafe { + ffi::g_dtls_connection_set_interaction( + self.as_ref().to_glib_none().0, + interaction.map(|p| p.as_ref()).to_glib_none().0, + ); + } + } + + #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] + #[allow(deprecated)] + #[doc(alias = "g_dtls_connection_set_rehandshake_mode")] + #[doc(alias = "rehandshake-mode")] + fn set_rehandshake_mode(&self, mode: TlsRehandshakeMode) { + unsafe { + ffi::g_dtls_connection_set_rehandshake_mode( + self.as_ref().to_glib_none().0, + mode.into_glib(), + ); + } + } + + #[doc(alias = "g_dtls_connection_set_require_close_notify")] + #[doc(alias = "require-close-notify")] + fn set_require_close_notify(&self, require_close_notify: bool) { + unsafe { + ffi::g_dtls_connection_set_require_close_notify( + self.as_ref().to_glib_none().0, + require_close_notify.into_glib(), + ); + } + } + + #[doc(alias = "g_dtls_connection_shutdown")] + fn shutdown( + &self, + shutdown_read: bool, + shutdown_write: bool, + cancellable: Option<&impl IsA>, + ) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::g_dtls_connection_shutdown( + self.as_ref().to_glib_none().0, + shutdown_read.into_glib(), + shutdown_write.into_glib(), + cancellable.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "g_dtls_connection_shutdown_async")] + fn shutdown_async) + 'static>( + &self, + shutdown_read: bool, + shutdown_write: bool, + io_priority: glib::Priority, + cancellable: Option<&impl IsA>, + callback: P, + ) { + let main_context = glib::MainContext::ref_thread_default(); + let is_main_context_owner = main_context.is_owner(); + let has_acquired_main_context = (!is_main_context_owner) + .then(|| main_context.acquire().ok()) + .flatten(); + assert!( + is_main_context_owner || has_acquired_main_context.is_some(), + "Async operations only allowed if the thread is owning the MainContext" + ); + + let user_data: Box_> = + Box_::new(glib::thread_guard::ThreadGuard::new(callback)); + unsafe extern "C" fn shutdown_async_trampoline< + P: FnOnce(Result<(), glib::Error>) + 'static, + >( + _source_object: *mut glib::gobject_ffi::GObject, + res: *mut crate::ffi::GAsyncResult, + user_data: glib::ffi::gpointer, + ) { + let mut error = std::ptr::null_mut(); + let _ = + ffi::g_dtls_connection_shutdown_finish(_source_object as *mut _, res, &mut error); + let result = if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + }; + let callback: Box_> = + Box_::from_raw(user_data as *mut _); + let callback: P = callback.into_inner(); + callback(result); + } + let callback = shutdown_async_trampoline::

; + unsafe { + ffi::g_dtls_connection_shutdown_async( + self.as_ref().to_glib_none().0, + shutdown_read.into_glib(), + shutdown_write.into_glib(), + io_priority.into_glib(), + cancellable.map(|p| p.as_ref()).to_glib_none().0, + Some(callback), + Box_::into_raw(user_data) as *mut _, + ); + } + } + + fn shutdown_future( + &self, + shutdown_read: bool, + shutdown_write: bool, + io_priority: glib::Priority, + ) -> Pin> + 'static>> { + Box_::pin(crate::GioFuture::new( + self, + move |obj, cancellable, send| { + obj.shutdown_async( + shutdown_read, + shutdown_write, + io_priority, + Some(cancellable), + move |res| { + send.resolve(res); + }, + ); + }, + )) + } + + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + #[doc(alias = "advertised-protocols")] + fn advertised_protocols(&self) -> Vec { + ObjectExt::property(self.as_ref(), "advertised-protocols") + } + + #[doc(alias = "base-socket")] + fn base_socket(&self) -> Option { + ObjectExt::property(self.as_ref(), "base-socket") + } + + #[doc(alias = "accept-certificate")] + fn connect_accept_certificate< + F: Fn(&Self, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, + >( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn accept_certificate_trampoline< + P: IsA, + F: Fn(&P, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, + >( + this: *mut ffi::GDtlsConnection, + peer_cert: *mut ffi::GTlsCertificate, + errors: ffi::GTlsCertificateFlags, + f: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { + let f: &F = &*(f as *const F); + f( + DtlsConnection::from_glib_borrow(this).unsafe_cast_ref(), + &from_glib_borrow(peer_cert), + from_glib(errors), + ) + .into_glib() + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"accept-certificate\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + accept_certificate_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + #[doc(alias = "advertised-protocols")] + fn connect_advertised_protocols_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_advertised_protocols_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::advertised-protocols\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_advertised_protocols_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "certificate")] + fn connect_certificate_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_certificate_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::certificate\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_certificate_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[cfg(feature = "v2_70")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] + #[doc(alias = "ciphersuite-name")] + fn connect_ciphersuite_name_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_ciphersuite_name_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::ciphersuite-name\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_ciphersuite_name_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "database")] + fn connect_database_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_database_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::database\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_database_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "interaction")] + fn connect_interaction_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_interaction_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::interaction\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_interaction_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[cfg(feature = "v2_60")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] + #[doc(alias = "negotiated-protocol")] + fn connect_negotiated_protocol_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_negotiated_protocol_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::negotiated-protocol\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_negotiated_protocol_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "peer-certificate")] + fn connect_peer_certificate_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_peer_certificate_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::peer-certificate\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_peer_certificate_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "peer-certificate-errors")] + fn connect_peer_certificate_errors_notify( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn notify_peer_certificate_errors_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::peer-certificate-errors\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_peer_certificate_errors_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[cfg(feature = "v2_70")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] + #[doc(alias = "protocol-version")] + fn connect_protocol_version_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_protocol_version_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::protocol-version\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_protocol_version_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] + #[doc(alias = "rehandshake-mode")] + fn connect_rehandshake_mode_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_rehandshake_mode_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::rehandshake-mode\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_rehandshake_mode_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "require-close-notify")] + fn connect_require_close_notify_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_require_close_notify_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::require-close-notify\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_require_close_notify_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> DtlsConnectionExt for O {} diff --git a/gio/src/auto/dtls_server_connection.rs b/gio/src/auto/dtls_server_connection.rs new file mode 100644 index 000000000000..78a1b9c2c2b5 --- /dev/null +++ b/gio/src/auto/dtls_server_connection.rs @@ -0,0 +1,84 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, DatagramBased, DtlsConnection, TlsAuthenticationMode, TlsCertificate}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GDtlsServerConnection")] + pub struct DtlsServerConnection(Interface) @requires DatagramBased, DtlsConnection; + + match fn { + type_ => || ffi::g_dtls_server_connection_get_type(), + } +} + +impl DtlsServerConnection { + pub const NONE: Option<&'static DtlsServerConnection> = None; + + #[doc(alias = "g_dtls_server_connection_new")] + pub fn new( + base_socket: &impl IsA, + certificate: Option<&impl IsA>, + ) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::g_dtls_server_connection_new( + base_socket.as_ref().to_glib_none().0, + certificate.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } +} + +pub trait DtlsServerConnectionExt: IsA + 'static { + #[doc(alias = "authentication-mode")] + fn authentication_mode(&self) -> TlsAuthenticationMode { + ObjectExt::property(self.as_ref(), "authentication-mode") + } + + #[doc(alias = "authentication-mode")] + fn set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode) { + ObjectExt::set_property(self.as_ref(), "authentication-mode", authentication_mode) + } + + #[doc(alias = "authentication-mode")] + fn connect_authentication_mode_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_authentication_mode_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GDtlsServerConnection, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(DtlsServerConnection::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::authentication-mode\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_authentication_mode_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> DtlsServerConnectionExt for O {} diff --git a/gio/src/auto/enums.rs b/gio/src/auto/enums.rs index f133bfdb7f49..8b472daf0ffa 100644 --- a/gio/src/auto/enums.rs +++ b/gio/src/auto/enums.rs @@ -325,6 +325,375 @@ impl From for glib::Value { } } +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GDBusError")] +pub enum DBusError { + #[doc(alias = "G_DBUS_ERROR_FAILED")] + Failed, + #[doc(alias = "G_DBUS_ERROR_NO_MEMORY")] + NoMemory, + #[doc(alias = "G_DBUS_ERROR_SERVICE_UNKNOWN")] + ServiceUnknown, + #[doc(alias = "G_DBUS_ERROR_NAME_HAS_NO_OWNER")] + NameHasNoOwner, + #[doc(alias = "G_DBUS_ERROR_NO_REPLY")] + NoReply, + #[doc(alias = "G_DBUS_ERROR_IO_ERROR")] + IoError, + #[doc(alias = "G_DBUS_ERROR_BAD_ADDRESS")] + BadAddress, + #[doc(alias = "G_DBUS_ERROR_NOT_SUPPORTED")] + NotSupported, + #[doc(alias = "G_DBUS_ERROR_LIMITS_EXCEEDED")] + LimitsExceeded, + #[doc(alias = "G_DBUS_ERROR_ACCESS_DENIED")] + AccessDenied, + #[doc(alias = "G_DBUS_ERROR_AUTH_FAILED")] + AuthFailed, + #[doc(alias = "G_DBUS_ERROR_NO_SERVER")] + NoServer, + #[doc(alias = "G_DBUS_ERROR_TIMEOUT")] + Timeout, + #[doc(alias = "G_DBUS_ERROR_NO_NETWORK")] + NoNetwork, + #[doc(alias = "G_DBUS_ERROR_ADDRESS_IN_USE")] + AddressInUse, + #[doc(alias = "G_DBUS_ERROR_DISCONNECTED")] + Disconnected, + #[doc(alias = "G_DBUS_ERROR_INVALID_ARGS")] + InvalidArgs, + #[doc(alias = "G_DBUS_ERROR_FILE_NOT_FOUND")] + FileNotFound, + #[doc(alias = "G_DBUS_ERROR_FILE_EXISTS")] + FileExists, + #[doc(alias = "G_DBUS_ERROR_UNKNOWN_METHOD")] + UnknownMethod, + #[doc(alias = "G_DBUS_ERROR_TIMED_OUT")] + TimedOut, + #[doc(alias = "G_DBUS_ERROR_MATCH_RULE_NOT_FOUND")] + MatchRuleNotFound, + #[doc(alias = "G_DBUS_ERROR_MATCH_RULE_INVALID")] + MatchRuleInvalid, + #[doc(alias = "G_DBUS_ERROR_SPAWN_EXEC_FAILED")] + SpawnExecFailed, + #[doc(alias = "G_DBUS_ERROR_SPAWN_FORK_FAILED")] + SpawnForkFailed, + #[doc(alias = "G_DBUS_ERROR_SPAWN_CHILD_EXITED")] + SpawnChildExited, + #[doc(alias = "G_DBUS_ERROR_SPAWN_CHILD_SIGNALED")] + SpawnChildSignaled, + #[doc(alias = "G_DBUS_ERROR_SPAWN_FAILED")] + SpawnFailed, + #[doc(alias = "G_DBUS_ERROR_SPAWN_SETUP_FAILED")] + SpawnSetupFailed, + #[doc(alias = "G_DBUS_ERROR_SPAWN_CONFIG_INVALID")] + SpawnConfigInvalid, + #[doc(alias = "G_DBUS_ERROR_SPAWN_SERVICE_INVALID")] + SpawnServiceInvalid, + #[doc(alias = "G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND")] + SpawnServiceNotFound, + #[doc(alias = "G_DBUS_ERROR_SPAWN_PERMISSIONS_INVALID")] + SpawnPermissionsInvalid, + #[doc(alias = "G_DBUS_ERROR_SPAWN_FILE_INVALID")] + SpawnFileInvalid, + #[doc(alias = "G_DBUS_ERROR_SPAWN_NO_MEMORY")] + SpawnNoMemory, + #[doc(alias = "G_DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN")] + UnixProcessIdUnknown, + #[doc(alias = "G_DBUS_ERROR_INVALID_SIGNATURE")] + InvalidSignature, + #[doc(alias = "G_DBUS_ERROR_INVALID_FILE_CONTENT")] + InvalidFileContent, + #[doc(alias = "G_DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN")] + SelinuxSecurityContextUnknown, + #[doc(alias = "G_DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN")] + AdtAuditDataUnknown, + #[doc(alias = "G_DBUS_ERROR_OBJECT_PATH_IN_USE")] + ObjectPathInUse, + #[doc(alias = "G_DBUS_ERROR_UNKNOWN_OBJECT")] + UnknownObject, + #[doc(alias = "G_DBUS_ERROR_UNKNOWN_INTERFACE")] + UnknownInterface, + #[doc(alias = "G_DBUS_ERROR_UNKNOWN_PROPERTY")] + UnknownProperty, + #[doc(alias = "G_DBUS_ERROR_PROPERTY_READ_ONLY")] + PropertyReadOnly, + #[doc(hidden)] + __Unknown(i32), +} + +impl DBusError { + #[doc(alias = "g_dbus_error_encode_gerror")] + pub fn encode_gerror(error: &glib::Error) -> glib::GString { + unsafe { from_glib_full(ffi::g_dbus_error_encode_gerror(error.to_glib_none().0)) } + } + + #[doc(alias = "g_dbus_error_get_remote_error")] + #[doc(alias = "get_remote_error")] + pub fn remote_error(error: &glib::Error) -> Option { + unsafe { from_glib_full(ffi::g_dbus_error_get_remote_error(error.to_glib_none().0)) } + } + + #[doc(alias = "g_dbus_error_is_remote_error")] + pub fn is_remote_error(error: &glib::Error) -> bool { + unsafe { from_glib(ffi::g_dbus_error_is_remote_error(error.to_glib_none().0)) } + } + + #[doc(alias = "g_dbus_error_new_for_dbus_error")] + pub fn new_for_dbus_error(dbus_error_name: &str, dbus_error_message: &str) -> glib::Error { + unsafe { + from_glib_full(ffi::g_dbus_error_new_for_dbus_error( + dbus_error_name.to_glib_none().0, + dbus_error_message.to_glib_none().0, + )) + } + } + + #[doc(alias = "g_dbus_error_register_error")] + pub fn register_error( + error_domain: glib::Quark, + error_code: i32, + dbus_error_name: &str, + ) -> bool { + unsafe { + from_glib(ffi::g_dbus_error_register_error( + error_domain.into_glib(), + error_code, + dbus_error_name.to_glib_none().0, + )) + } + } + + //#[doc(alias = "g_dbus_error_register_error_domain")] + //pub fn register_error_domain(error_domain_quark_name: &str, quark_volatile: usize, entries: /*Ignored*/&[DBusErrorEntry]) { + // unsafe { TODO: call ffi:g_dbus_error_register_error_domain() } + //} + + //#[doc(alias = "g_dbus_error_set_dbus_error")] + //pub fn set_dbus_error(error: &mut glib::Error, dbus_error_name: &str, dbus_error_message: &str, format: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { + // unsafe { TODO: call ffi:g_dbus_error_set_dbus_error() } + //} + + //#[doc(alias = "g_dbus_error_set_dbus_error_valist")] + //pub fn set_dbus_error_valist(error: &mut glib::Error, dbus_error_name: &str, dbus_error_message: &str, format: Option<&str>, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) { + // unsafe { TODO: call ffi:g_dbus_error_set_dbus_error_valist() } + //} + + #[doc(alias = "g_dbus_error_strip_remote_error")] + pub fn strip_remote_error(error: &mut glib::Error) -> bool { + unsafe { + from_glib(ffi::g_dbus_error_strip_remote_error( + error.to_glib_none_mut().0, + )) + } + } + + #[doc(alias = "g_dbus_error_unregister_error")] + pub fn unregister_error( + error_domain: glib::Quark, + error_code: i32, + dbus_error_name: &str, + ) -> bool { + unsafe { + from_glib(ffi::g_dbus_error_unregister_error( + error_domain.into_glib(), + error_code, + dbus_error_name.to_glib_none().0, + )) + } + } +} + +#[doc(hidden)] +impl IntoGlib for DBusError { + type GlibType = ffi::GDBusError; + + fn into_glib(self) -> ffi::GDBusError { + match self { + Self::Failed => ffi::G_DBUS_ERROR_FAILED, + Self::NoMemory => ffi::G_DBUS_ERROR_NO_MEMORY, + Self::ServiceUnknown => ffi::G_DBUS_ERROR_SERVICE_UNKNOWN, + Self::NameHasNoOwner => ffi::G_DBUS_ERROR_NAME_HAS_NO_OWNER, + Self::NoReply => ffi::G_DBUS_ERROR_NO_REPLY, + Self::IoError => ffi::G_DBUS_ERROR_IO_ERROR, + Self::BadAddress => ffi::G_DBUS_ERROR_BAD_ADDRESS, + Self::NotSupported => ffi::G_DBUS_ERROR_NOT_SUPPORTED, + Self::LimitsExceeded => ffi::G_DBUS_ERROR_LIMITS_EXCEEDED, + Self::AccessDenied => ffi::G_DBUS_ERROR_ACCESS_DENIED, + Self::AuthFailed => ffi::G_DBUS_ERROR_AUTH_FAILED, + Self::NoServer => ffi::G_DBUS_ERROR_NO_SERVER, + Self::Timeout => ffi::G_DBUS_ERROR_TIMEOUT, + Self::NoNetwork => ffi::G_DBUS_ERROR_NO_NETWORK, + Self::AddressInUse => ffi::G_DBUS_ERROR_ADDRESS_IN_USE, + Self::Disconnected => ffi::G_DBUS_ERROR_DISCONNECTED, + Self::InvalidArgs => ffi::G_DBUS_ERROR_INVALID_ARGS, + Self::FileNotFound => ffi::G_DBUS_ERROR_FILE_NOT_FOUND, + Self::FileExists => ffi::G_DBUS_ERROR_FILE_EXISTS, + Self::UnknownMethod => ffi::G_DBUS_ERROR_UNKNOWN_METHOD, + Self::TimedOut => ffi::G_DBUS_ERROR_TIMED_OUT, + Self::MatchRuleNotFound => ffi::G_DBUS_ERROR_MATCH_RULE_NOT_FOUND, + Self::MatchRuleInvalid => ffi::G_DBUS_ERROR_MATCH_RULE_INVALID, + Self::SpawnExecFailed => ffi::G_DBUS_ERROR_SPAWN_EXEC_FAILED, + Self::SpawnForkFailed => ffi::G_DBUS_ERROR_SPAWN_FORK_FAILED, + Self::SpawnChildExited => ffi::G_DBUS_ERROR_SPAWN_CHILD_EXITED, + Self::SpawnChildSignaled => ffi::G_DBUS_ERROR_SPAWN_CHILD_SIGNALED, + Self::SpawnFailed => ffi::G_DBUS_ERROR_SPAWN_FAILED, + Self::SpawnSetupFailed => ffi::G_DBUS_ERROR_SPAWN_SETUP_FAILED, + Self::SpawnConfigInvalid => ffi::G_DBUS_ERROR_SPAWN_CONFIG_INVALID, + Self::SpawnServiceInvalid => ffi::G_DBUS_ERROR_SPAWN_SERVICE_INVALID, + Self::SpawnServiceNotFound => ffi::G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND, + Self::SpawnPermissionsInvalid => ffi::G_DBUS_ERROR_SPAWN_PERMISSIONS_INVALID, + Self::SpawnFileInvalid => ffi::G_DBUS_ERROR_SPAWN_FILE_INVALID, + Self::SpawnNoMemory => ffi::G_DBUS_ERROR_SPAWN_NO_MEMORY, + Self::UnixProcessIdUnknown => ffi::G_DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN, + Self::InvalidSignature => ffi::G_DBUS_ERROR_INVALID_SIGNATURE, + Self::InvalidFileContent => ffi::G_DBUS_ERROR_INVALID_FILE_CONTENT, + Self::SelinuxSecurityContextUnknown => { + ffi::G_DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN + } + Self::AdtAuditDataUnknown => ffi::G_DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN, + Self::ObjectPathInUse => ffi::G_DBUS_ERROR_OBJECT_PATH_IN_USE, + Self::UnknownObject => ffi::G_DBUS_ERROR_UNKNOWN_OBJECT, + Self::UnknownInterface => ffi::G_DBUS_ERROR_UNKNOWN_INTERFACE, + Self::UnknownProperty => ffi::G_DBUS_ERROR_UNKNOWN_PROPERTY, + Self::PropertyReadOnly => ffi::G_DBUS_ERROR_PROPERTY_READ_ONLY, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for DBusError { + unsafe fn from_glib(value: ffi::GDBusError) -> Self { + match value { + ffi::G_DBUS_ERROR_FAILED => Self::Failed, + ffi::G_DBUS_ERROR_NO_MEMORY => Self::NoMemory, + ffi::G_DBUS_ERROR_SERVICE_UNKNOWN => Self::ServiceUnknown, + ffi::G_DBUS_ERROR_NAME_HAS_NO_OWNER => Self::NameHasNoOwner, + ffi::G_DBUS_ERROR_NO_REPLY => Self::NoReply, + ffi::G_DBUS_ERROR_IO_ERROR => Self::IoError, + ffi::G_DBUS_ERROR_BAD_ADDRESS => Self::BadAddress, + ffi::G_DBUS_ERROR_NOT_SUPPORTED => Self::NotSupported, + ffi::G_DBUS_ERROR_LIMITS_EXCEEDED => Self::LimitsExceeded, + ffi::G_DBUS_ERROR_ACCESS_DENIED => Self::AccessDenied, + ffi::G_DBUS_ERROR_AUTH_FAILED => Self::AuthFailed, + ffi::G_DBUS_ERROR_NO_SERVER => Self::NoServer, + ffi::G_DBUS_ERROR_TIMEOUT => Self::Timeout, + ffi::G_DBUS_ERROR_NO_NETWORK => Self::NoNetwork, + ffi::G_DBUS_ERROR_ADDRESS_IN_USE => Self::AddressInUse, + ffi::G_DBUS_ERROR_DISCONNECTED => Self::Disconnected, + ffi::G_DBUS_ERROR_INVALID_ARGS => Self::InvalidArgs, + ffi::G_DBUS_ERROR_FILE_NOT_FOUND => Self::FileNotFound, + ffi::G_DBUS_ERROR_FILE_EXISTS => Self::FileExists, + ffi::G_DBUS_ERROR_UNKNOWN_METHOD => Self::UnknownMethod, + ffi::G_DBUS_ERROR_TIMED_OUT => Self::TimedOut, + ffi::G_DBUS_ERROR_MATCH_RULE_NOT_FOUND => Self::MatchRuleNotFound, + ffi::G_DBUS_ERROR_MATCH_RULE_INVALID => Self::MatchRuleInvalid, + ffi::G_DBUS_ERROR_SPAWN_EXEC_FAILED => Self::SpawnExecFailed, + ffi::G_DBUS_ERROR_SPAWN_FORK_FAILED => Self::SpawnForkFailed, + ffi::G_DBUS_ERROR_SPAWN_CHILD_EXITED => Self::SpawnChildExited, + ffi::G_DBUS_ERROR_SPAWN_CHILD_SIGNALED => Self::SpawnChildSignaled, + ffi::G_DBUS_ERROR_SPAWN_FAILED => Self::SpawnFailed, + ffi::G_DBUS_ERROR_SPAWN_SETUP_FAILED => Self::SpawnSetupFailed, + ffi::G_DBUS_ERROR_SPAWN_CONFIG_INVALID => Self::SpawnConfigInvalid, + ffi::G_DBUS_ERROR_SPAWN_SERVICE_INVALID => Self::SpawnServiceInvalid, + ffi::G_DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND => Self::SpawnServiceNotFound, + ffi::G_DBUS_ERROR_SPAWN_PERMISSIONS_INVALID => Self::SpawnPermissionsInvalid, + ffi::G_DBUS_ERROR_SPAWN_FILE_INVALID => Self::SpawnFileInvalid, + ffi::G_DBUS_ERROR_SPAWN_NO_MEMORY => Self::SpawnNoMemory, + ffi::G_DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN => Self::UnixProcessIdUnknown, + ffi::G_DBUS_ERROR_INVALID_SIGNATURE => Self::InvalidSignature, + ffi::G_DBUS_ERROR_INVALID_FILE_CONTENT => Self::InvalidFileContent, + ffi::G_DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN => { + Self::SelinuxSecurityContextUnknown + } + ffi::G_DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN => Self::AdtAuditDataUnknown, + ffi::G_DBUS_ERROR_OBJECT_PATH_IN_USE => Self::ObjectPathInUse, + ffi::G_DBUS_ERROR_UNKNOWN_OBJECT => Self::UnknownObject, + ffi::G_DBUS_ERROR_UNKNOWN_INTERFACE => Self::UnknownInterface, + ffi::G_DBUS_ERROR_UNKNOWN_PROPERTY => Self::UnknownProperty, + ffi::G_DBUS_ERROR_PROPERTY_READ_ONLY => Self::PropertyReadOnly, + value => Self::__Unknown(value), + } + } +} + +impl glib::error::ErrorDomain for DBusError { + #[inline] + fn domain() -> glib::Quark { + unsafe { from_glib(ffi::g_dbus_error_quark()) } + } + + #[inline] + fn code(self) -> i32 { + self.into_glib() + } + + #[inline] + #[allow(clippy::match_single_binding)] + fn from(code: i32) -> Option { + match unsafe { from_glib(code) } { + Self::__Unknown(_) => Some(Self::Failed), + value => Some(value), + } + } +} + +impl StaticType for DBusError { + #[inline] + #[doc(alias = "g_dbus_error_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_dbus_error_get_type()) } + } +} + +impl glib::HasParamSpec for DBusError { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for DBusError { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for DBusError { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for DBusError { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: DBusError) -> Self { + ToValue::to_value(&v) + } +} + #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GDBusMessageByteOrder")] @@ -1505,6 +1874,102 @@ impl From for glib::Value { } } +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GFilesystemPreviewType")] +pub enum FilesystemPreviewType { + #[doc(alias = "G_FILESYSTEM_PREVIEW_TYPE_IF_ALWAYS")] + IfAlways, + #[doc(alias = "G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL")] + IfLocal, + #[doc(alias = "G_FILESYSTEM_PREVIEW_TYPE_NEVER")] + Never, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for FilesystemPreviewType { + type GlibType = ffi::GFilesystemPreviewType; + + #[inline] + fn into_glib(self) -> ffi::GFilesystemPreviewType { + match self { + Self::IfAlways => ffi::G_FILESYSTEM_PREVIEW_TYPE_IF_ALWAYS, + Self::IfLocal => ffi::G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL, + Self::Never => ffi::G_FILESYSTEM_PREVIEW_TYPE_NEVER, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for FilesystemPreviewType { + #[inline] + unsafe fn from_glib(value: ffi::GFilesystemPreviewType) -> Self { + match value { + ffi::G_FILESYSTEM_PREVIEW_TYPE_IF_ALWAYS => Self::IfAlways, + ffi::G_FILESYSTEM_PREVIEW_TYPE_IF_LOCAL => Self::IfLocal, + ffi::G_FILESYSTEM_PREVIEW_TYPE_NEVER => Self::Never, + value => Self::__Unknown(value), + } + } +} + +impl StaticType for FilesystemPreviewType { + #[inline] + #[doc(alias = "g_filesystem_preview_type_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_filesystem_preview_type_get_type()) } + } +} + +impl glib::HasParamSpec for FilesystemPreviewType { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for FilesystemPreviewType { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for FilesystemPreviewType { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for FilesystemPreviewType { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: FilesystemPreviewType) -> Self { + ToValue::to_value(&v) + } +} + #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GIOErrorEnum")] @@ -1812,6 +2277,98 @@ impl From for glib::Value { } } +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GIOModuleScopeFlags")] +pub enum IOModuleScopeFlags { + #[doc(alias = "G_IO_MODULE_SCOPE_NONE")] + None, + #[doc(alias = "G_IO_MODULE_SCOPE_BLOCK_DUPLICATES")] + BlockDuplicates, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for IOModuleScopeFlags { + type GlibType = ffi::GIOModuleScopeFlags; + + #[inline] + fn into_glib(self) -> ffi::GIOModuleScopeFlags { + match self { + Self::None => ffi::G_IO_MODULE_SCOPE_NONE, + Self::BlockDuplicates => ffi::G_IO_MODULE_SCOPE_BLOCK_DUPLICATES, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for IOModuleScopeFlags { + #[inline] + unsafe fn from_glib(value: ffi::GIOModuleScopeFlags) -> Self { + match value { + ffi::G_IO_MODULE_SCOPE_NONE => Self::None, + ffi::G_IO_MODULE_SCOPE_BLOCK_DUPLICATES => Self::BlockDuplicates, + value => Self::__Unknown(value), + } + } +} + +impl StaticType for IOModuleScopeFlags { + #[inline] + #[doc(alias = "g_io_module_scope_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_io_module_scope_flags_get_type()) } + } +} + +impl glib::HasParamSpec for IOModuleScopeFlags { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for IOModuleScopeFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for IOModuleScopeFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for IOModuleScopeFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: IOModuleScopeFlags) -> Self { + ToValue::to_value(&v) + } +} + #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] @@ -3472,6 +4029,150 @@ impl From for glib::Value { } } +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GTlsChannelBindingError")] +pub enum TlsChannelBindingError { + #[doc(alias = "G_TLS_CHANNEL_BINDING_ERROR_NOT_IMPLEMENTED")] + NotImplemented, + #[doc(alias = "G_TLS_CHANNEL_BINDING_ERROR_INVALID_STATE")] + InvalidState, + #[doc(alias = "G_TLS_CHANNEL_BINDING_ERROR_NOT_AVAILABLE")] + NotAvailable, + #[doc(alias = "G_TLS_CHANNEL_BINDING_ERROR_NOT_SUPPORTED")] + NotSupported, + #[doc(alias = "G_TLS_CHANNEL_BINDING_ERROR_GENERAL_ERROR")] + GeneralError, + #[doc(hidden)] + __Unknown(i32), +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +#[doc(hidden)] +impl IntoGlib for TlsChannelBindingError { + type GlibType = ffi::GTlsChannelBindingError; + + #[inline] + fn into_glib(self) -> ffi::GTlsChannelBindingError { + match self { + Self::NotImplemented => ffi::G_TLS_CHANNEL_BINDING_ERROR_NOT_IMPLEMENTED, + Self::InvalidState => ffi::G_TLS_CHANNEL_BINDING_ERROR_INVALID_STATE, + Self::NotAvailable => ffi::G_TLS_CHANNEL_BINDING_ERROR_NOT_AVAILABLE, + Self::NotSupported => ffi::G_TLS_CHANNEL_BINDING_ERROR_NOT_SUPPORTED, + Self::GeneralError => ffi::G_TLS_CHANNEL_BINDING_ERROR_GENERAL_ERROR, + Self::__Unknown(value) => value, + } + } +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +#[doc(hidden)] +impl FromGlib for TlsChannelBindingError { + #[inline] + unsafe fn from_glib(value: ffi::GTlsChannelBindingError) -> Self { + match value { + ffi::G_TLS_CHANNEL_BINDING_ERROR_NOT_IMPLEMENTED => Self::NotImplemented, + ffi::G_TLS_CHANNEL_BINDING_ERROR_INVALID_STATE => Self::InvalidState, + ffi::G_TLS_CHANNEL_BINDING_ERROR_NOT_AVAILABLE => Self::NotAvailable, + ffi::G_TLS_CHANNEL_BINDING_ERROR_NOT_SUPPORTED => Self::NotSupported, + ffi::G_TLS_CHANNEL_BINDING_ERROR_GENERAL_ERROR => Self::GeneralError, + value => Self::__Unknown(value), + } + } +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +impl glib::error::ErrorDomain for TlsChannelBindingError { + #[inline] + fn domain() -> glib::Quark { + unsafe { from_glib(ffi::g_tls_channel_binding_error_quark()) } + } + + #[inline] + fn code(self) -> i32 { + self.into_glib() + } + + #[inline] + #[allow(clippy::match_single_binding)] + fn from(code: i32) -> Option { + match unsafe { from_glib(code) } { + value => Some(value), + } + } +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +impl StaticType for TlsChannelBindingError { + #[inline] + #[doc(alias = "g_tls_channel_binding_error_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_tls_channel_binding_error_get_type()) } + } +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +impl glib::HasParamSpec for TlsChannelBindingError { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +impl glib::value::ValueType for TlsChannelBindingError { + type Type = Self; +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +unsafe impl<'a> glib::value::FromValue<'a> for TlsChannelBindingError { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +impl ToValue for TlsChannelBindingError { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +impl From for glib::Value { + #[inline] + fn from(v: TlsChannelBindingError) -> Self { + ToValue::to_value(&v) + } +} + #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] diff --git a/gio/src/auto/flags.rs b/gio/src/auto/flags.rs index 017aaac64695..a94668ca20e8 100644 --- a/gio/src/auto/flags.rs +++ b/gio/src/auto/flags.rs @@ -1055,6 +1055,91 @@ impl From for glib::Value { } } +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GDBusPropertyInfoFlags")] + pub struct DBusPropertyInfoFlags: u32 { + #[doc(alias = "G_DBUS_PROPERTY_INFO_FLAGS_NONE")] + const NONE = ffi::G_DBUS_PROPERTY_INFO_FLAGS_NONE as _; + #[doc(alias = "G_DBUS_PROPERTY_INFO_FLAGS_READABLE")] + const READABLE = ffi::G_DBUS_PROPERTY_INFO_FLAGS_READABLE as _; + #[doc(alias = "G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE")] + const WRITABLE = ffi::G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE as _; + } +} + +#[doc(hidden)] +impl IntoGlib for DBusPropertyInfoFlags { + type GlibType = ffi::GDBusPropertyInfoFlags; + + #[inline] + fn into_glib(self) -> ffi::GDBusPropertyInfoFlags { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for DBusPropertyInfoFlags { + #[inline] + unsafe fn from_glib(value: ffi::GDBusPropertyInfoFlags) -> Self { + Self::from_bits_truncate(value) + } +} + +impl StaticType for DBusPropertyInfoFlags { + #[inline] + #[doc(alias = "g_dbus_property_info_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_dbus_property_info_flags_get_type()) } + } +} + +impl glib::HasParamSpec for DBusPropertyInfoFlags { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for DBusPropertyInfoFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for DBusPropertyInfoFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for DBusPropertyInfoFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: DBusPropertyInfoFlags) -> Self { + ToValue::to_value(&v) + } +} + bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusProxyFlags")] @@ -1407,6 +1492,89 @@ impl From for glib::Value { } } +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GDBusSubtreeFlags")] + pub struct DBusSubtreeFlags: u32 { + #[doc(alias = "G_DBUS_SUBTREE_FLAGS_NONE")] + const NONE = ffi::G_DBUS_SUBTREE_FLAGS_NONE as _; + #[doc(alias = "G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES")] + const DISPATCH_TO_UNENUMERATED_NODES = ffi::G_DBUS_SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES as _; + } +} + +#[doc(hidden)] +impl IntoGlib for DBusSubtreeFlags { + type GlibType = ffi::GDBusSubtreeFlags; + + #[inline] + fn into_glib(self) -> ffi::GDBusSubtreeFlags { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for DBusSubtreeFlags { + #[inline] + unsafe fn from_glib(value: ffi::GDBusSubtreeFlags) -> Self { + Self::from_bits_truncate(value) + } +} + +impl StaticType for DBusSubtreeFlags { + #[inline] + #[doc(alias = "g_dbus_subtree_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_dbus_subtree_flags_get_type()) } + } +} + +impl glib::HasParamSpec for DBusSubtreeFlags { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for DBusSubtreeFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for DBusSubtreeFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for DBusSubtreeFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: DBusSubtreeFlags) -> Self { + ToValue::to_value(&v) + } +} + bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDriveStartFlags")] @@ -2453,6 +2621,89 @@ impl From for glib::Value { } } +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GResourceFlags")] + pub struct ResourceFlags: u32 { + #[doc(alias = "G_RESOURCE_FLAGS_NONE")] + const NONE = ffi::G_RESOURCE_FLAGS_NONE as _; + #[doc(alias = "G_RESOURCE_FLAGS_COMPRESSED")] + const COMPRESSED = ffi::G_RESOURCE_FLAGS_COMPRESSED as _; + } +} + +#[doc(hidden)] +impl IntoGlib for ResourceFlags { + type GlibType = ffi::GResourceFlags; + + #[inline] + fn into_glib(self) -> ffi::GResourceFlags { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for ResourceFlags { + #[inline] + unsafe fn from_glib(value: ffi::GResourceFlags) -> Self { + Self::from_bits_truncate(value) + } +} + +impl StaticType for ResourceFlags { + #[inline] + #[doc(alias = "g_resource_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_resource_flags_get_type()) } + } +} + +impl glib::HasParamSpec for ResourceFlags { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for ResourceFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for ResourceFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for ResourceFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: ResourceFlags) -> Self { + ToValue::to_value(&v) + } +} + bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GResourceLookupFlags")] @@ -2726,6 +2977,87 @@ impl From for glib::Value { } } +bitflags! { + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] + #[doc(alias = "GTestDBusFlags")] + pub struct TestDBusFlags: u32 { + #[doc(alias = "G_TEST_DBUS_NONE")] + const NONE = ffi::G_TEST_DBUS_NONE as _; + } +} + +#[doc(hidden)] +impl IntoGlib for TestDBusFlags { + type GlibType = ffi::GTestDBusFlags; + + #[inline] + fn into_glib(self) -> ffi::GTestDBusFlags { + self.bits() + } +} + +#[doc(hidden)] +impl FromGlib for TestDBusFlags { + #[inline] + unsafe fn from_glib(value: ffi::GTestDBusFlags) -> Self { + Self::from_bits_truncate(value) + } +} + +impl StaticType for TestDBusFlags { + #[inline] + #[doc(alias = "g_test_dbus_flags_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::g_test_dbus_flags_get_type()) } + } +} + +impl glib::HasParamSpec for TestDBusFlags { + type ParamSpec = glib::ParamSpecFlags; + type SetValue = Self; + type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder + } +} + +impl glib::value::ValueType for TestDBusFlags { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for TestDBusFlags { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) + } +} + +impl ToValue for TestDBusFlags { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: TestDBusFlags) -> Self { + ToValue::to_value(&v) + } +} + bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GTlsCertificateFlags")] diff --git a/gio/src/auto/mod.rs b/gio/src/auto/mod.rs index 909490e7abcb..e8b3c5958f6c 100644 --- a/gio/src/auto/mod.rs +++ b/gio/src/auto/mod.rs @@ -89,6 +89,15 @@ pub use self::dbus_object::DBusObject; mod dbus_object_manager; pub use self::dbus_object_manager::DBusObjectManager; +mod dbus_object_manager_server; +pub use self::dbus_object_manager_server::DBusObjectManagerServer; + +mod dbus_object_proxy; +pub use self::dbus_object_proxy::DBusObjectProxy; + +mod dbus_object_skeleton; +pub use self::dbus_object_skeleton::DBusObjectSkeleton; + mod dbus_proxy; pub use self::dbus_proxy::DBusProxy; @@ -128,6 +137,15 @@ pub use self::desktop_app_info::DesktopAppInfo; mod drive; pub use self::drive::Drive; +mod dtls_client_connection; +pub use self::dtls_client_connection::DtlsClientConnection; + +mod dtls_connection; +pub use self::dtls_connection::DtlsConnection; + +mod dtls_server_connection; +pub use self::dtls_server_connection::DtlsServerConnection; + mod emblem; pub use self::emblem::Emblem; @@ -231,6 +249,12 @@ pub use self::mount::Mount; mod mount_operation; pub use self::mount_operation::MountOperation; +mod native_socket_address; +pub use self::native_socket_address::NativeSocketAddress; + +mod native_volume_monitor; +pub use self::native_volume_monitor::NativeVolumeMonitor; + mod network_address; pub use self::network_address::NetworkAddress; @@ -271,6 +295,9 @@ pub use self::proxy::Proxy; mod proxy_address; pub use self::proxy_address::ProxyAddress; +mod proxy_address_enumerator; +pub use self::proxy_address_enumerator::ProxyAddressEnumerator; + mod proxy_resolver; pub use self::proxy_resolver::ProxyResolver; @@ -340,6 +367,12 @@ pub use self::subprocess_launcher::SubprocessLauncher; mod tcp_connection; pub use self::tcp_connection::TcpConnection; +mod tcp_wrapper_connection; +pub use self::tcp_wrapper_connection::TcpWrapperConnection; + +mod test_dbus; +pub use self::test_dbus::TestDBus; + mod themed_icon; pub use self::themed_icon::ThemedIcon; @@ -373,6 +406,13 @@ pub use self::tls_password::TlsPassword; mod tls_server_connection; pub use self::tls_server_connection::TlsServerConnection; +#[cfg(unix)] +#[cfg_attr(docsrs, doc(cfg(unix)))] +mod unix_connection; +#[cfg(unix)] +#[cfg_attr(docsrs, doc(cfg(unix)))] +pub use self::unix_connection::UnixConnection; + #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_credentials_message; @@ -401,6 +441,13 @@ mod unix_input_stream; #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_input_stream::UnixInputStream; +#[cfg(unix)] +#[cfg_attr(docsrs, doc(cfg(unix)))] +mod unix_mount_monitor; +#[cfg(unix)] +#[cfg_attr(docsrs, doc(cfg(unix)))] +pub use self::unix_mount_monitor::UnixMountMonitor; + #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_output_stream; @@ -487,6 +534,7 @@ mod enums; pub use self::enums::BusType; pub use self::enums::ConverterResult; pub use self::enums::CredentialsType; +pub use self::enums::DBusError; pub use self::enums::DBusMessageByteOrder; pub use self::enums::DBusMessageHeaderField; pub use self::enums::DBusMessageType; @@ -498,7 +546,9 @@ pub use self::enums::FileAttributeStatus; pub use self::enums::FileAttributeType; pub use self::enums::FileMonitorEvent; pub use self::enums::FileType; +pub use self::enums::FilesystemPreviewType; pub use self::enums::IOErrorEnum; +pub use self::enums::IOModuleScopeFlags; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] pub use self::enums::MemoryMonitorWarningLevel; @@ -521,6 +571,9 @@ pub use self::enums::TlsAuthenticationMode; pub use self::enums::TlsCertificateRequestFlags; #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] +pub use self::enums::TlsChannelBindingError; +#[cfg(feature = "v2_66")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] pub use self::enums::TlsChannelBindingType; pub use self::enums::TlsDatabaseLookupFlags; pub use self::enums::TlsError; @@ -548,10 +601,12 @@ pub use self::flags::DBusConnectionFlags; pub use self::flags::DBusInterfaceSkeletonFlags; pub use self::flags::DBusMessageFlags; pub use self::flags::DBusObjectManagerClientFlags; +pub use self::flags::DBusPropertyInfoFlags; pub use self::flags::DBusProxyFlags; pub use self::flags::DBusSendMessageFlags; pub use self::flags::DBusServerFlags; pub use self::flags::DBusSignalFlags; +pub use self::flags::DBusSubtreeFlags; pub use self::flags::DriveStartFlags; pub use self::flags::FileAttributeInfoFlags; pub use self::flags::FileCopyFlags; @@ -566,9 +621,11 @@ pub use self::flags::OutputStreamSpliceFlags; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] pub use self::flags::ResolverNameLookupFlags; +pub use self::flags::ResourceFlags; pub use self::flags::ResourceLookupFlags; pub use self::flags::SettingsBindFlags; pub use self::flags::SubprocessFlags; +pub use self::flags::TestDBusFlags; pub use self::flags::TlsCertificateFlags; pub use self::flags::TlsDatabaseVerifyFlags; pub use self::flags::TlsPasswordFlags; @@ -771,6 +828,9 @@ pub(crate) mod traits { pub use super::dbus_interface_skeleton::DBusInterfaceSkeletonExt; pub use super::dbus_object::DBusObjectExt; pub use super::dbus_object_manager::DBusObjectManagerExt; + pub use super::dbus_object_manager_server::DBusObjectManagerServerExt; + pub use super::dbus_object_proxy::DBusObjectProxyExt; + pub use super::dbus_object_skeleton::DBusObjectSkeletonExt; pub use super::dbus_proxy::DBusProxyExt; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] @@ -779,6 +839,9 @@ pub(crate) mod traits { #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use super::debug_controller_dbus::DebugControllerDBusExt; pub use super::drive::DriveExt; + pub use super::dtls_client_connection::DtlsClientConnectionExt; + pub use super::dtls_connection::DtlsConnectionExt; + pub use super::dtls_server_connection::DtlsServerConnectionExt; pub use super::emblemed_icon::EmblemedIconExt; pub use super::file::FileExt; pub use super::file_enumerator::FileEnumeratorExt; @@ -819,6 +882,7 @@ pub(crate) mod traits { pub use super::power_profile_monitor::PowerProfileMonitorExt; pub use super::proxy::ProxyExt; pub use super::proxy_address::ProxyAddressExt; + pub use super::proxy_address_enumerator::ProxyAddressEnumeratorExt; pub use super::proxy_resolver::ProxyResolverExt; pub use super::remote_action_group::RemoteActionGroupExt; pub use super::resolver::ResolverExt; @@ -836,6 +900,7 @@ pub(crate) mod traits { pub use super::socket_listener::SocketListenerExt; pub use super::socket_service::SocketServiceExt; pub use super::tcp_connection::TcpConnectionExt; + pub use super::tcp_wrapper_connection::TcpWrapperConnectionExt; pub use super::threaded_socket_service::ThreadedSocketServiceExt; pub use super::tls_backend::TlsBackendExt; pub use super::tls_certificate::TlsCertificateExt; @@ -848,6 +913,9 @@ pub(crate) mod traits { pub use super::tls_server_connection::TlsServerConnectionExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] + pub use super::unix_connection::UnixConnectionExt; + #[cfg(unix)] + #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_credentials_message::UnixCredentialsMessageExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] diff --git a/gio/src/auto/native_socket_address.rs b/gio/src/auto/native_socket_address.rs new file mode 100644 index 000000000000..c715faca6f48 --- /dev/null +++ b/gio/src/auto/native_socket_address.rs @@ -0,0 +1,23 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, SocketAddress, SocketConnectable}; + +glib::wrapper! { + #[doc(alias = "GNativeSocketAddress")] + pub struct NativeSocketAddress(Object) @extends SocketAddress, @implements SocketConnectable; + + match fn { + type_ => || ffi::g_native_socket_address_get_type(), + } +} + +impl NativeSocketAddress { + pub const NONE: Option<&'static NativeSocketAddress> = None; + + //#[doc(alias = "g_native_socket_address_new")] + //pub fn new(native: /*Unimplemented*/Option, len: usize) -> NativeSocketAddress { + // unsafe { TODO: call ffi:g_native_socket_address_new() } + //} +} diff --git a/gio/src/auto/native_volume_monitor.rs b/gio/src/auto/native_volume_monitor.rs new file mode 100644 index 000000000000..ad163d742963 --- /dev/null +++ b/gio/src/auto/native_volume_monitor.rs @@ -0,0 +1,18 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, VolumeMonitor}; + +glib::wrapper! { + #[doc(alias = "GNativeVolumeMonitor")] + pub struct NativeVolumeMonitor(Object) @extends VolumeMonitor; + + match fn { + type_ => || ffi::g_native_volume_monitor_get_type(), + } +} + +impl NativeVolumeMonitor { + pub const NONE: Option<&'static NativeVolumeMonitor> = None; +} diff --git a/gio/src/auto/proxy_address_enumerator.rs b/gio/src/auto/proxy_address_enumerator.rs new file mode 100644 index 000000000000..561b21243ceb --- /dev/null +++ b/gio/src/auto/proxy_address_enumerator.rs @@ -0,0 +1,77 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, ProxyResolver, SocketAddressEnumerator, SocketConnectable}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GProxyAddressEnumerator")] + pub struct ProxyAddressEnumerator(Object) @extends SocketAddressEnumerator; + + match fn { + type_ => || ffi::g_proxy_address_enumerator_get_type(), + } +} + +impl ProxyAddressEnumerator { + pub const NONE: Option<&'static ProxyAddressEnumerator> = None; +} + +pub trait ProxyAddressEnumeratorExt: IsA + 'static { + fn connectable(&self) -> Option { + ObjectExt::property(self.as_ref(), "connectable") + } + + #[doc(alias = "default-port")] + fn default_port(&self) -> u32 { + ObjectExt::property(self.as_ref(), "default-port") + } + + #[doc(alias = "proxy-resolver")] + fn proxy_resolver(&self) -> Option { + ObjectExt::property(self.as_ref(), "proxy-resolver") + } + + #[doc(alias = "proxy-resolver")] + fn set_proxy_resolver>(&self, proxy_resolver: Option<&P>) { + ObjectExt::set_property(self.as_ref(), "proxy-resolver", proxy_resolver) + } + + fn uri(&self) -> Option { + ObjectExt::property(self.as_ref(), "uri") + } + + #[doc(alias = "proxy-resolver")] + fn connect_proxy_resolver_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_proxy_resolver_trampoline< + P: IsA, + F: Fn(&P) + 'static, + >( + this: *mut ffi::GProxyAddressEnumerator, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(ProxyAddressEnumerator::from_glib_borrow(this).unsafe_cast_ref()) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"notify::proxy-resolver\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_proxy_resolver_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +impl> ProxyAddressEnumeratorExt for O {} diff --git a/gio/src/auto/tcp_wrapper_connection.rs b/gio/src/auto/tcp_wrapper_connection.rs new file mode 100644 index 000000000000..8d9db7ec3649 --- /dev/null +++ b/gio/src/auto/tcp_wrapper_connection.rs @@ -0,0 +1,48 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, IOStream, Socket, SocketConnection, TcpConnection}; +use glib::{prelude::*, translate::*}; + +glib::wrapper! { + #[doc(alias = "GTcpWrapperConnection")] + pub struct TcpWrapperConnection(Object) @extends TcpConnection, SocketConnection, IOStream; + + match fn { + type_ => || ffi::g_tcp_wrapper_connection_get_type(), + } +} + +impl TcpWrapperConnection { + pub const NONE: Option<&'static TcpWrapperConnection> = None; + + #[doc(alias = "g_tcp_wrapper_connection_new")] + pub fn new( + base_io_stream: &impl IsA, + socket: &impl IsA, + ) -> TcpWrapperConnection { + unsafe { + SocketConnection::from_glib_full(ffi::g_tcp_wrapper_connection_new( + base_io_stream.as_ref().to_glib_none().0, + socket.as_ref().to_glib_none().0, + )) + .unsafe_cast() + } + } +} + +pub trait TcpWrapperConnectionExt: IsA + 'static { + #[doc(alias = "g_tcp_wrapper_connection_get_base_io_stream")] + #[doc(alias = "get_base_io_stream")] + #[doc(alias = "base-io-stream")] + fn base_io_stream(&self) -> IOStream { + unsafe { + from_glib_none(ffi::g_tcp_wrapper_connection_get_base_io_stream( + self.as_ref().to_glib_none().0, + )) + } + } +} + +impl> TcpWrapperConnectionExt for O {} diff --git a/gio/src/auto/test_dbus.rs b/gio/src/auto/test_dbus.rs new file mode 100644 index 000000000000..6708f3329797 --- /dev/null +++ b/gio/src/auto/test_dbus.rs @@ -0,0 +1,69 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, TestDBusFlags}; +use glib::translate::*; + +glib::wrapper! { + #[doc(alias = "GTestDBus")] + pub struct TestDBus(Object); + + match fn { + type_ => || ffi::g_test_dbus_get_type(), + } +} + +impl TestDBus { + #[doc(alias = "g_test_dbus_new")] + pub fn new(flags: TestDBusFlags) -> TestDBus { + unsafe { from_glib_full(ffi::g_test_dbus_new(flags.into_glib())) } + } + + #[doc(alias = "g_test_dbus_add_service_dir")] + pub fn add_service_dir(&self, path: &str) { + unsafe { + ffi::g_test_dbus_add_service_dir(self.to_glib_none().0, path.to_glib_none().0); + } + } + + #[doc(alias = "g_test_dbus_down")] + pub fn down(&self) { + unsafe { + ffi::g_test_dbus_down(self.to_glib_none().0); + } + } + + #[doc(alias = "g_test_dbus_get_bus_address")] + #[doc(alias = "get_bus_address")] + pub fn bus_address(&self) -> Option { + unsafe { from_glib_none(ffi::g_test_dbus_get_bus_address(self.to_glib_none().0)) } + } + + #[doc(alias = "g_test_dbus_get_flags")] + #[doc(alias = "get_flags")] + pub fn flags(&self) -> TestDBusFlags { + unsafe { from_glib(ffi::g_test_dbus_get_flags(self.to_glib_none().0)) } + } + + #[doc(alias = "g_test_dbus_stop")] + pub fn stop(&self) { + unsafe { + ffi::g_test_dbus_stop(self.to_glib_none().0); + } + } + + #[doc(alias = "g_test_dbus_up")] + pub fn up(&self) { + unsafe { + ffi::g_test_dbus_up(self.to_glib_none().0); + } + } + + #[doc(alias = "g_test_dbus_unset")] + pub fn unset() { + unsafe { + ffi::g_test_dbus_unset(); + } + } +} diff --git a/gio/src/auto/unix_connection.rs b/gio/src/auto/unix_connection.rs new file mode 100644 index 000000000000..b98bebbfe563 --- /dev/null +++ b/gio/src/auto/unix_connection.rs @@ -0,0 +1,236 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, AsyncResult, Cancellable, Credentials, IOStream, SocketConnection}; +use glib::{prelude::*, translate::*}; +use std::{boxed::Box as Box_, pin::Pin}; + +glib::wrapper! { + #[doc(alias = "GUnixConnection")] + pub struct UnixConnection(Object) @extends SocketConnection, IOStream; + + match fn { + type_ => || ffi::g_unix_connection_get_type(), + } +} + +impl UnixConnection { + pub const NONE: Option<&'static UnixConnection> = None; +} + +pub trait UnixConnectionExt: IsA + 'static { + #[doc(alias = "g_unix_connection_receive_credentials")] + fn receive_credentials( + &self, + cancellable: Option<&impl IsA>, + ) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::g_unix_connection_receive_credentials( + self.as_ref().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "g_unix_connection_receive_credentials_async")] + fn receive_credentials_async) + 'static>( + &self, + cancellable: Option<&impl IsA>, + callback: P, + ) { + let main_context = glib::MainContext::ref_thread_default(); + let is_main_context_owner = main_context.is_owner(); + let has_acquired_main_context = (!is_main_context_owner) + .then(|| main_context.acquire().ok()) + .flatten(); + assert!( + is_main_context_owner || has_acquired_main_context.is_some(), + "Async operations only allowed if the thread is owning the MainContext" + ); + + let user_data: Box_> = + Box_::new(glib::thread_guard::ThreadGuard::new(callback)); + unsafe extern "C" fn receive_credentials_async_trampoline< + P: FnOnce(Result) + 'static, + >( + _source_object: *mut glib::gobject_ffi::GObject, + res: *mut crate::ffi::GAsyncResult, + user_data: glib::ffi::gpointer, + ) { + let mut error = std::ptr::null_mut(); + let ret = ffi::g_unix_connection_receive_credentials_finish( + _source_object as *mut _, + res, + &mut error, + ); + let result = if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + }; + let callback: Box_> = + Box_::from_raw(user_data as *mut _); + let callback: P = callback.into_inner(); + callback(result); + } + let callback = receive_credentials_async_trampoline::

; + unsafe { + ffi::g_unix_connection_receive_credentials_async( + self.as_ref().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + Some(callback), + Box_::into_raw(user_data) as *mut _, + ); + } + } + + fn receive_credentials_future( + &self, + ) -> Pin> + 'static>> + { + Box_::pin(crate::GioFuture::new( + self, + move |obj, cancellable, send| { + obj.receive_credentials_async(Some(cancellable), move |res| { + send.resolve(res); + }); + }, + )) + } + + #[doc(alias = "g_unix_connection_receive_fd")] + fn receive_fd(&self, cancellable: Option<&impl IsA>) -> Result { + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::g_unix_connection_receive_fd( + self.as_ref().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + if error.is_null() { + Ok(ret) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "g_unix_connection_send_credentials")] + fn send_credentials( + &self, + cancellable: Option<&impl IsA>, + ) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::g_unix_connection_send_credentials( + self.as_ref().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "g_unix_connection_send_credentials_async")] + fn send_credentials_async) + 'static>( + &self, + cancellable: Option<&impl IsA>, + callback: P, + ) { + let main_context = glib::MainContext::ref_thread_default(); + let is_main_context_owner = main_context.is_owner(); + let has_acquired_main_context = (!is_main_context_owner) + .then(|| main_context.acquire().ok()) + .flatten(); + assert!( + is_main_context_owner || has_acquired_main_context.is_some(), + "Async operations only allowed if the thread is owning the MainContext" + ); + + let user_data: Box_> = + Box_::new(glib::thread_guard::ThreadGuard::new(callback)); + unsafe extern "C" fn send_credentials_async_trampoline< + P: FnOnce(Result<(), glib::Error>) + 'static, + >( + _source_object: *mut glib::gobject_ffi::GObject, + res: *mut crate::ffi::GAsyncResult, + user_data: glib::ffi::gpointer, + ) { + let mut error = std::ptr::null_mut(); + let _ = ffi::g_unix_connection_send_credentials_finish( + _source_object as *mut _, + res, + &mut error, + ); + let result = if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + }; + let callback: Box_> = + Box_::from_raw(user_data as *mut _); + let callback: P = callback.into_inner(); + callback(result); + } + let callback = send_credentials_async_trampoline::

; + unsafe { + ffi::g_unix_connection_send_credentials_async( + self.as_ref().to_glib_none().0, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + Some(callback), + Box_::into_raw(user_data) as *mut _, + ); + } + } + + fn send_credentials_future( + &self, + ) -> Pin> + 'static>> { + Box_::pin(crate::GioFuture::new( + self, + move |obj, cancellable, send| { + obj.send_credentials_async(Some(cancellable), move |res| { + send.resolve(res); + }); + }, + )) + } + + #[doc(alias = "g_unix_connection_send_fd")] + fn send_fd( + &self, + fd: i32, + cancellable: Option<&impl IsA>, + ) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::g_unix_connection_send_fd( + self.as_ref().to_glib_none().0, + fd, + cancellable.map(|p| p.as_ref()).to_glib_none().0, + &mut error, + ); + debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); + if error.is_null() { + Ok(()) + } else { + Err(from_glib_full(error)) + } + } + } +} + +impl> UnixConnectionExt for O {} diff --git a/gio/src/auto/unix_mount_monitor.rs b/gio/src/auto/unix_mount_monitor.rs new file mode 100644 index 000000000000..c21dd90a9a60 --- /dev/null +++ b/gio/src/auto/unix_mount_monitor.rs @@ -0,0 +1,71 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::ffi; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GUnixMountMonitor")] + pub struct UnixMountMonitor(Object); + + match fn { + type_ => || ffi::g_unix_mount_monitor_get_type(), + } +} + +impl UnixMountMonitor { + #[doc(alias = "g_unix_mount_monitor_get")] + pub fn get() -> UnixMountMonitor { + unsafe { from_glib_full(ffi::g_unix_mount_monitor_get()) } + } + + #[doc(alias = "mountpoints-changed")] + pub fn connect_mountpoints_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn mountpoints_changed_trampoline( + this: *mut ffi::GUnixMountMonitor, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"mountpoints-changed\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + mountpoints_changed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[doc(alias = "mounts-changed")] + pub fn connect_mounts_changed(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn mounts_changed_trampoline( + this: *mut ffi::GUnixMountMonitor, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"mounts-changed\0".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + mounts_changed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +}