From e82972105ba642218a9c3ff9607855d6887c2340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 17 Nov 2024 13:02:52 +0200 Subject: [PATCH 01/23] glib: Add `Bytes::into_data() and `Bytes::from_bytes()` bindings --- glib/src/bytes.rs | 74 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/glib/src/bytes.rs b/glib/src/bytes.rs index 777b24dd8ca1..3ae586fcc91d 100644 --- a/glib/src/bytes.rs +++ b/glib/src/bytes.rs @@ -5,7 +5,8 @@ use std::{ cmp::Ordering, fmt, hash::{Hash, Hasher}, - ops::Deref, + mem, + ops::{Bound, Deref, RangeBounds}, slice, }; @@ -64,6 +65,7 @@ impl Bytes { // rustdoc-stripper-ignore-next /// Takes ownership of `data` and creates a new `Bytes` without copying. + #[doc(alias = "g_bytes_new")] pub fn from_owned + Send + 'static>(data: T) -> Bytes { let data: Box = Box::new(data); let (size, data_ptr) = { @@ -84,6 +86,56 @@ impl Bytes { )) } } + + // rustdoc-stripper-ignore-next + /// Returns the underlying data of the `Bytes`. + /// + /// If there is no other reference to `self` then this does not copy the data, otherwise + /// it is copied into newly allocated heap memory. + #[doc(alias = "g_bytes_unref_to_data")] + pub fn into_data(self) -> crate::collections::Slice { + unsafe { + let mut size = mem::MaybeUninit::uninit(); + let ret = ffi::g_bytes_unref_to_data(self.into_glib_ptr(), size.as_mut_ptr()); + crate::collections::Slice::from_glib_full_num(ret as *mut u8, size.assume_init()) + } + } + + fn calculate_offset_size(&self, range: impl RangeBounds) -> (usize, usize) { + let len = self.len(); + + let start_offset = match range.start_bound() { + Bound::Included(v) => *v, + Bound::Excluded(v) => v.checked_add(1).expect("Invalid start offset"), + Bound::Unbounded => 0, + }; + assert!(start_offset < len, "Start offset after valid range"); + + let end_offset = match range.end_bound() { + Bound::Included(v) => v.checked_add(1).expect("Invalid end offset"), + Bound::Excluded(v) => *v, + Bound::Unbounded => len, + }; + assert!(end_offset <= len, "End offset after valid range"); + + let size = end_offset.saturating_sub(start_offset); + + (start_offset, size) + } + + // rustdoc-stripper-ignore-next + /// Creates a new `Bytes` that references the given `range` of `bytes`. + #[doc(alias = "g_bytes_new_from_bytes")] + pub fn from_bytes(bytes: &Self, range: impl RangeBounds) -> Self { + let (offset, size) = bytes.calculate_offset_size(range); + unsafe { + from_glib_full(ffi::g_bytes_new_from_bytes( + bytes.to_glib_none().0, + offset, + size, + )) + } + } } unsafe impl Send for Bytes {} @@ -274,4 +326,24 @@ mod tests { let b = Bytes::from_owned(vec![1, 2, 3]); assert_eq!(b, [1u8, 2u8, 3u8].as_ref()); } + + #[test] + fn from_bytes() { + let b1 = Bytes::from_owned(vec![1, 2, 3]); + let b2 = Bytes::from_bytes(&b1, 1..=1); + assert_eq!(b2, [2u8].as_ref()); + let b2 = Bytes::from_bytes(&b1, 1..); + assert_eq!(b2, [2u8, 3u8].as_ref()); + let b2 = Bytes::from_bytes(&b1, ..2); + assert_eq!(b2, [1u8, 2u8].as_ref()); + let b2 = Bytes::from_bytes(&b1, ..); + assert_eq!(b2, [1u8, 2u8, 3u8].as_ref()); + } + + #[test] + pub fn into_data() { + let b = Bytes::from(b"this is a test"); + let d = b.into_data(); + assert_eq!(d.as_slice(), b"this is a test"); + } } From 36becc323ef0f39b17be369a6667c4c6e41b08e0 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Sun, 27 Oct 2024 21:41:38 +0100 Subject: [PATCH 02/23] Add convenience function to return a result --- examples/gio_dbus_register_object/main.rs | 17 ++++++++++------- gio/src/dbus_method_invocation.rs | 21 ++++++++++++++++++++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/examples/gio_dbus_register_object/main.rs b/examples/gio_dbus_register_object/main.rs index 8915dd9561a3..de36ca577848 100644 --- a/examples/gio_dbus_register_object/main.rs +++ b/examples/gio_dbus_register_object/main.rs @@ -28,13 +28,16 @@ fn on_startup(app: &gio::Application, tx: &Sender) { move |_, _, _, _, method, params, invocation| { match method { "Hello" => { - if let Some((name,)) = <(String,)>::from_variant(¶ms) { - let greet = format!("Hello {name}!"); - println!("{greet}"); - invocation.return_value(Some(&(greet,).to_variant())); - } else { - invocation.return_error(gio::IOErrorEnum::Failed, "Invalid parameters"); - } + let result = <(String,)>::from_variant(¶ms) + .ok_or_else(|| { + glib::Error::new(gio::IOErrorEnum::Failed, "Invalid parameters") + }) + .map(|(name,)| { + let greet = format!("Hello {name}!"); + println!("{greet}"); + Some(greet.to_variant()) + }); + invocation.return_result(result); } _ => unreachable!(), } diff --git a/gio/src/dbus_method_invocation.rs b/gio/src/dbus_method_invocation.rs index 01d8cf3869c3..f4fca0da9dc0 100644 --- a/gio/src/dbus_method_invocation.rs +++ b/gio/src/dbus_method_invocation.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::{prelude::*, translate::*}; +use glib::{prelude::*, translate::*, VariantTy}; use crate::{ffi, DBusMethodInvocation}; @@ -26,4 +26,23 @@ impl DBusMethodInvocation { ); } } + + // rustdoc-stripper-ignore-next + /// Return a result for this invocation. + /// + /// If `Ok` return the contained value with [`return_value`]. If the return + /// value is not a tuple, automatically convert it to a one-element tuple, as + /// DBus return values must be tuples. + /// + /// If `Err` return the contained error with [`return_gerror`]. + pub fn return_result(self, result: Result, glib::Error>) { + match result { + Ok(Some(value)) if !value.is_type(VariantTy::TUPLE) => { + let tupled = glib::Variant::tuple_from_iter(std::iter::once(value)); + self.return_value(Some(&tupled)); + } + Ok(value) => self.return_value(value.as_ref()), + Err(error) => self.return_gerror(error), + } + } } From 951b00cebb1ec2b49fb2ade903f51aa3c6bf47de Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Sun, 27 Oct 2024 21:51:43 +0100 Subject: [PATCH 03/23] Streamline call dispatching in example --- examples/gio_dbus_register_object/main.rs | 43 +++++++++++++++-------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/examples/gio_dbus_register_object/main.rs b/examples/gio_dbus_register_object/main.rs index de36ca577848..8cb403ca95f4 100644 --- a/examples/gio_dbus_register_object/main.rs +++ b/examples/gio_dbus_register_object/main.rs @@ -1,4 +1,4 @@ -use gio::prelude::*; +use gio::{prelude::*, IOErrorEnum}; use std::sync::mpsc::{channel, Receiver, Sender}; const EXAMPLE_XML: &str = r#" @@ -12,6 +12,26 @@ const EXAMPLE_XML: &str = r#" "#; +#[derive(Debug, glib::Variant)] +struct Hello { + name: String, +} + +#[derive(Debug)] +enum Call { + Hello(Hello), +} + +impl Call { + pub fn parse(method: &str, parameters: glib::Variant) -> Result { + match method { + "Hello" => Ok(parameters.get::().map(Call::Hello)), + _ => Err(glib::Error::new(IOErrorEnum::Failed, "No such method")), + } + .and_then(|p| p.ok_or_else(|| glib::Error::new(IOErrorEnum::Failed, "Invalid parameters"))) + } +} + fn on_startup(app: &gio::Application, tx: &Sender) { let connection = app.dbus_connection().expect("connection"); @@ -26,21 +46,14 @@ fn on_startup(app: &gio::Application, tx: &Sender) { #[strong] app, move |_, _, _, _, method, params, invocation| { - match method { - "Hello" => { - let result = <(String,)>::from_variant(¶ms) - .ok_or_else(|| { - glib::Error::new(gio::IOErrorEnum::Failed, "Invalid parameters") - }) - .map(|(name,)| { - let greet = format!("Hello {name}!"); - println!("{greet}"); - Some(greet.to_variant()) - }); - invocation.return_result(result); + let result = Call::parse(method, params).map(|call| match call { + Call::Hello(Hello { name }) => { + let greet = format!("Hello {name}!"); + println!("{greet}"); + Some(greet.to_variant()) } - _ => unreachable!(), - } + }); + invocation.return_result(result); app.quit(); } )) From 0d787bbc98a95dd8db5f7578cf37d42348b2d2f9 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Mon, 28 Oct 2024 17:38:50 +0100 Subject: [PATCH 04/23] Add helper to return result from a future --- gio/src/dbus_method_invocation.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gio/src/dbus_method_invocation.rs b/gio/src/dbus_method_invocation.rs index f4fca0da9dc0..65150a8a4afd 100644 --- a/gio/src/dbus_method_invocation.rs +++ b/gio/src/dbus_method_invocation.rs @@ -45,4 +45,25 @@ impl DBusMethodInvocation { Err(error) => self.return_gerror(error), } } + + // rustdoc-stripper-ignore-next + /// Return an async result for this invocation. + /// + /// Spawn the given future on the thread-default main context, and return the + /// the result with [`return_result`]. Specifically, if a variant is returned + /// that is not a tuple it is automatically wrapped into a tuple. + /// + /// The given `Future` does not have to be `Send`. + /// + /// This can be called only from the thread where the main context is running, e.g. + /// from any other `Future` that is executed on this main context, or after calling + /// `with_thread_default` or `acquire` on the main context. + pub fn return_future_local(self, f: F) -> glib::JoinHandle<()> + where + F: std::future::Future, glib::Error>> + 'static, + { + glib::spawn_future_local(async move { + self.return_result(f.await); + }) + } } From 74c7835eb541c6a6e1297a89d816a1e6b23e3fa9 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Mon, 28 Oct 2024 17:39:17 +0100 Subject: [PATCH 05/23] Demo async call handling for gdbus --- examples/gio_dbus_register_object/main.rs | 43 ++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/examples/gio_dbus_register_object/main.rs b/examples/gio_dbus_register_object/main.rs index 8cb403ca95f4..37a4143e8453 100644 --- a/examples/gio_dbus_register_object/main.rs +++ b/examples/gio_dbus_register_object/main.rs @@ -1,5 +1,8 @@ use gio::{prelude::*, IOErrorEnum}; -use std::sync::mpsc::{channel, Receiver, Sender}; +use std::{ + sync::mpsc::{channel, Receiver, Sender}, + time::Duration, +}; const EXAMPLE_XML: &str = r#" @@ -8,6 +11,11 @@ const EXAMPLE_XML: &str = r#" + + + + + "#; @@ -17,15 +25,23 @@ struct Hello { name: String, } +#[derive(Debug, glib::Variant)] +struct SlowHello { + name: String, + delay: u32, +} + #[derive(Debug)] enum Call { Hello(Hello), + SlowHello(SlowHello), } impl Call { pub fn parse(method: &str, parameters: glib::Variant) -> Result { match method { "Hello" => Ok(parameters.get::().map(Call::Hello)), + "SlowHello" => Ok(parameters.get::().map(Call::SlowHello)), _ => Err(glib::Error::new(IOErrorEnum::Failed, "No such method")), } .and_then(|p| p.ok_or_else(|| glib::Error::new(IOErrorEnum::Failed, "Invalid parameters"))) @@ -42,21 +58,24 @@ fn on_startup(app: &gio::Application, tx: &Sender) { if let Ok(id) = connection .register_object("/com/github/gtk_rs/examples/HelloWorld", &example) - .method_call(glib::clone!( - #[strong] - app, - move |_, _, _, _, method, params, invocation| { - let result = Call::parse(method, params).map(|call| match call { + .method_call(move |_, _, _, _, method, params, invocation| { + let call = Call::parse(method, params); + invocation.return_future_local(async move { + match call? { Call::Hello(Hello { name }) => { let greet = format!("Hello {name}!"); println!("{greet}"); - Some(greet.to_variant()) + Ok(Some(greet.to_variant())) + } + Call::SlowHello(SlowHello { name, delay }) => { + glib::timeout_future(Duration::from_secs(delay as u64)).await; + let greet = format!("Hello {name} after {delay} seconds!"); + println!("{greet}"); + Ok(Some(greet.to_variant())) } - }); - invocation.return_result(result); - app.quit(); - } - )) + } + }); + }) .build() { println!("Registered object"); From a846e416e88e023ac2af3e5f71d351f2dad0c145 Mon Sep 17 00:00:00 2001 From: Sebastian Wiesner Date: Thu, 31 Oct 2024 07:54:34 +0100 Subject: [PATCH 06/23] Add DBusMethodCall convenience trait This trait represents a parsed method call with deserialized arguments, to abstract over call parsing. Then add new registration builder helpers to register method calls with a simplified callback which receives parsed arguments, and can optionally return an async result. --- examples/gio_dbus_register_object/main.rs | 30 +++--- gio/src/dbus_connection.rs | 118 +++++++++++++++++++++- gio/src/prelude.rs | 9 +- 3 files changed, 138 insertions(+), 19 deletions(-) diff --git a/examples/gio_dbus_register_object/main.rs b/examples/gio_dbus_register_object/main.rs index 37a4143e8453..f3422e232aeb 100644 --- a/examples/gio_dbus_register_object/main.rs +++ b/examples/gio_dbus_register_object/main.rs @@ -32,16 +32,21 @@ struct SlowHello { } #[derive(Debug)] -enum Call { +enum HelloMethod { Hello(Hello), SlowHello(SlowHello), } -impl Call { - pub fn parse(method: &str, parameters: glib::Variant) -> Result { +impl DBusMethodCall for HelloMethod { + fn parse_call( + _obj_path: &str, + _interface: &str, + method: &str, + params: glib::Variant, + ) -> Result { match method { - "Hello" => Ok(parameters.get::().map(Call::Hello)), - "SlowHello" => Ok(parameters.get::().map(Call::SlowHello)), + "Hello" => Ok(params.get::().map(Self::Hello)), + "SlowHello" => Ok(params.get::().map(Self::SlowHello)), _ => Err(glib::Error::new(IOErrorEnum::Failed, "No such method")), } .and_then(|p| p.ok_or_else(|| glib::Error::new(IOErrorEnum::Failed, "Invalid parameters"))) @@ -58,23 +63,24 @@ fn on_startup(app: &gio::Application, tx: &Sender) { if let Ok(id) = connection .register_object("/com/github/gtk_rs/examples/HelloWorld", &example) - .method_call(move |_, _, _, _, method, params, invocation| { - let call = Call::parse(method, params); - invocation.return_future_local(async move { - match call? { - Call::Hello(Hello { name }) => { + .typed_method_call::() + .invoke_and_return_future_local(|_, sender, call| { + println!("Method call from {sender}"); + async { + match call { + HelloMethod::Hello(Hello { name }) => { let greet = format!("Hello {name}!"); println!("{greet}"); Ok(Some(greet.to_variant())) } - Call::SlowHello(SlowHello { name, delay }) => { + HelloMethod::SlowHello(SlowHello { name, delay }) => { glib::timeout_future(Duration::from_secs(delay as u64)).await; let greet = format!("Hello {name} after {delay} seconds!"); println!("{greet}"); Ok(Some(greet.to_variant())) } } - }); + } }) .build() { diff --git a/gio/src/dbus_connection.rs b/gio/src/dbus_connection.rs index f7ee74e7fbf7..d9b15e98cb1e 100644 --- a/gio/src/dbus_connection.rs +++ b/gio/src/dbus_connection.rs @@ -1,13 +1,110 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::{boxed::Box as Box_, num::NonZeroU32}; - -use glib::{prelude::*, translate::*}; +use std::{boxed::Box as Box_, future::Future, marker::PhantomData, num::NonZeroU32}; use crate::{ ffi, ActionGroup, DBusConnection, DBusInterfaceInfo, DBusMessage, DBusMethodInvocation, DBusSignalFlags, MenuModel, }; +use glib::{prelude::*, translate::*}; + +pub trait DBusMethodCall: Sized { + fn parse_call( + obj_path: &str, + interface: &str, + method: &str, + params: glib::Variant, + ) -> Result; +} + +// rustdoc-stripper-ignore-next +/// Handle method invocations. +pub struct MethodCallBuilder<'a, T> { + registration: RegistrationBuilder<'a>, + capture_type: PhantomData, +} + +impl<'a, T: DBusMethodCall> MethodCallBuilder<'a, T> { + // rustdoc-stripper-ignore-next + /// Handle invocation of a parsed method call. + /// + /// For each DBus method call parse the call, and then invoke the given closure + /// with + /// + /// 1. the DBus connection object, + /// 2. the name of the sender of the method call, + /// 3. the parsed call, and + /// 4. the method invocation object. + /// + /// The closure **must** return a value through the invocation object in all + /// code paths, using any of its `return_` functions, such as + /// [`DBusMethodInvocation::return_result`] or + /// [`DBusMethodInvocation::return_future_local`], to finish the call. + /// + /// If direct access to the invocation object is not needed, + /// [`invoke_and_return`] and [`invoke_and_return_future_local`] provide a + /// safer interface where the callback returns a result directly. + pub fn invoke(self, f: F) -> RegistrationBuilder<'a> + where + F: Fn(DBusConnection, &str, T, DBusMethodInvocation) + 'static, + { + self.registration.method_call( + move |connection, sender, obj_path, interface, method, params, invocation| { + match T::parse_call(obj_path, interface, method, params) { + Ok(call) => f(connection, sender, call, invocation), + Err(error) => invocation.return_gerror(error), + } + }, + ) + } + + // rustdoc-stripper-ignore-next + /// Handle invocation of a parsed method call. + /// + /// For each DBus method call parse the call, and then invoke the given closure + /// with + /// + /// 1. the DBus connection object, + /// 2. the name of the sender of the method call, and + /// 3. the parsed call. + /// + /// The return value of the closure is then returned on the method call. + /// If the returned variant value is not a tuple, it is automatically wrapped + /// in a single element tuple, as DBus methods must always return tuples. + /// See [`DBusMethodInvocation::return_result`] for details. + pub fn invoke_and_return(self, f: F) -> RegistrationBuilder<'a> + where + F: Fn(DBusConnection, &str, T) -> Result, glib::Error> + 'static, + { + self.invoke(move |connection, sender, call, invocation| { + invocation.return_result(f(connection, sender, call)) + }) + } + + // rustdoc-stripper-ignore-next + /// Handle an async invocation of a parsed method call. + /// + /// For each DBus method call parse the call, and then invoke the given closure + /// with + /// + /// 1. the DBus connection object, + /// 2. the name of the sender of the method call, and + /// 3. the parsed call. + /// + /// The output of the future is then returned on the method call. + /// If the returned variant value is not a tuple, it is automatically wrapped + /// in a single element tuple, as DBus methods must always return tuples. + /// See [`DBusMethodInvocation::return_future_local`] for details. + pub fn invoke_and_return_future_local(self, f: F) -> RegistrationBuilder<'a> + where + F: Fn(DBusConnection, &str, T) -> Fut + 'static, + Fut: Future, glib::Error>> + 'static, + { + self.invoke(move |connection, sender, call, invocation| { + invocation.return_future_local(f(connection, sender, call)); + }) + } +} #[derive(Debug, Eq, PartialEq)] pub struct RegistrationId(NonZeroU32); @@ -22,6 +119,8 @@ pub struct FilterId(NonZeroU32); #[derive(Debug, Eq, PartialEq)] pub struct SignalSubscriptionId(NonZeroU32); +// rustdoc-stripper-ignore-next +/// Build a registered DBus object, by handling different parts of DBus. #[must_use = "The builder must be built to be used"] pub struct RegistrationBuilder<'a> { connection: &'a DBusConnection, @@ -49,6 +148,19 @@ impl<'a> RegistrationBuilder<'a> { self } + // rustdoc-stripper-ignore-next + /// Handle method calls on this object. + /// + /// Return a builder for method calls which parses method names and + /// parameters with the given [`DBusMethodCall`] and then allows to dispatch + /// the parsed call either synchronously or asynchronously. + pub fn typed_method_call(self) -> MethodCallBuilder<'a, T> { + MethodCallBuilder { + registration: self, + capture_type: Default::default(), + } + } + #[doc(alias = "get_property")] pub fn property glib::Variant + 'static>( mut self, diff --git a/gio/src/prelude.rs b/gio/src/prelude.rs index 9c9e1998c57c..05bef53b4480 100644 --- a/gio/src/prelude.rs +++ b/gio/src/prelude.rs @@ -35,10 +35,11 @@ pub use crate::{ action_map::ActionMapExtManual, application::ApplicationExtManual, auto::traits::*, cancellable::CancellableExtManual, converter::ConverterExtManual, data_input_stream::DataInputStreamExtManual, datagram_based::DatagramBasedExtManual, - dbus_proxy::DBusProxyExtManual, file::FileExtManual, file_enumerator::FileEnumeratorExtManual, - inet_address::InetAddressExtManual, input_stream::InputStreamExtManual, - io_stream::IOStreamExtManual, list_model::ListModelExtManual, - output_stream::OutputStreamExtManual, pollable_input_stream::PollableInputStreamExtManual, + dbus_connection::DBusMethodCall, dbus_proxy::DBusProxyExtManual, file::FileExtManual, + file_enumerator::FileEnumeratorExtManual, inet_address::InetAddressExtManual, + input_stream::InputStreamExtManual, io_stream::IOStreamExtManual, + list_model::ListModelExtManual, output_stream::OutputStreamExtManual, + pollable_input_stream::PollableInputStreamExtManual, pollable_output_stream::PollableOutputStreamExtManual, settings::SettingsExtManual, simple_proxy_resolver::SimpleProxyResolverExtManual, socket::SocketExtManual, socket_control_message::SocketControlMessageExtManual, From 05c8ec5900d635dd0014b3f0c4e52a277733af0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 29 Nov 2024 17:23:59 +0200 Subject: [PATCH 07/23] Fix / silence various new Rust 1.83 clippy warnings --- gdk-pixbuf/src/lib.rs | 1 + glib/src/gobject/binding_group.rs | 2 +- glib/src/lib.rs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gdk-pixbuf/src/lib.rs b/gdk-pixbuf/src/lib.rs index 27f100b07564..1d662e697f2c 100644 --- a/gdk-pixbuf/src/lib.rs +++ b/gdk-pixbuf/src/lib.rs @@ -1,5 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#![allow(clippy::manual_c_str_literals)] #![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] diff --git a/glib/src/gobject/binding_group.rs b/glib/src/gobject/binding_group.rs index 52800e08a7dd..d71f4b9fd151 100644 --- a/glib/src/gobject/binding_group.rs +++ b/glib/src/gobject/binding_group.rs @@ -34,7 +34,7 @@ pub struct BindingGroupBuilder<'a> { transform_from: TransformFn, } -impl<'a> fmt::Debug for BindingGroupBuilder<'a> { +impl fmt::Debug for BindingGroupBuilder<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("BindingGroupBuilder") .field("group", &self.group) diff --git a/glib/src/lib.rs b/glib/src/lib.rs index 382a3d528894..a4ed600ef0f1 100644 --- a/glib/src/lib.rs +++ b/glib/src/lib.rs @@ -2,6 +2,7 @@ #![cfg_attr(docsrs, feature(doc_cfg))] #![allow(clippy::missing_safety_doc)] +#![allow(clippy::manual_c_str_literals)] #![allow(renamed_and_removed_lints)] // Override docs references to point to locally generated docs // rustdoc-stripper-ignore-next From 0092cc29db363d5754d4ef004484446d1b56c0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 30 Nov 2024 13:14:02 +0200 Subject: [PATCH 08/23] gio: Fix nullability of various DBus method call related parameters Fixes https://github.com/gtk-rs/gtk-rs-core/issues/1585 --- examples/gio_dbus_register_object/main.rs | 4 +- gio/Gir.toml | 11 ++++- gio/src/auto/dbus_method_invocation.rs | 4 +- gio/src/dbus_connection.rs | 50 ++++++++++++++++------- 4 files changed, 50 insertions(+), 19 deletions(-) diff --git a/examples/gio_dbus_register_object/main.rs b/examples/gio_dbus_register_object/main.rs index f3422e232aeb..e5d5302aa767 100644 --- a/examples/gio_dbus_register_object/main.rs +++ b/examples/gio_dbus_register_object/main.rs @@ -40,7 +40,7 @@ enum HelloMethod { impl DBusMethodCall for HelloMethod { fn parse_call( _obj_path: &str, - _interface: &str, + _interface: Option<&str>, method: &str, params: glib::Variant, ) -> Result { @@ -65,7 +65,7 @@ fn on_startup(app: &gio::Application, tx: &Sender) { .register_object("/com/github/gtk_rs/examples/HelloWorld", &example) .typed_method_call::() .invoke_and_return_future_local(|_, sender, call| { - println!("Method call from {sender}"); + println!("Method call from {sender:?}"); async { match call { HelloMethod::Hello(Hello { name }) => { diff --git a/gio/Gir.toml b/gio/Gir.toml index 68a361347600..05c34f6f1a63 100644 --- a/gio/Gir.toml +++ b/gio/Gir.toml @@ -644,7 +644,16 @@ status = "generate" name = "return_error_literal" # glib::ErrorDomain manual = true - + [[object.function]] + name = "get_sender" + [object.function.return] + # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4414 + nullable = true + [[object.function]] + name = "get_interface_name" + [object.function.return] + # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4414 + nullable = true [[object]] name = "Gio.DBusProxy" diff --git a/gio/src/auto/dbus_method_invocation.rs b/gio/src/auto/dbus_method_invocation.rs index 4f658a22b03e..4a6c38b50e41 100644 --- a/gio/src/auto/dbus_method_invocation.rs +++ b/gio/src/auto/dbus_method_invocation.rs @@ -33,7 +33,7 @@ impl DBusMethodInvocation { #[doc(alias = "g_dbus_method_invocation_get_interface_name")] #[doc(alias = "get_interface_name")] - pub fn interface_name(&self) -> glib::GString { + pub fn interface_name(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_interface_name( self.to_glib_none().0, @@ -103,7 +103,7 @@ impl DBusMethodInvocation { #[doc(alias = "g_dbus_method_invocation_get_sender")] #[doc(alias = "get_sender")] - pub fn sender(&self) -> glib::GString { + pub fn sender(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_sender( self.to_glib_none().0, diff --git a/gio/src/dbus_connection.rs b/gio/src/dbus_connection.rs index d9b15e98cb1e..2e46f9bc3279 100644 --- a/gio/src/dbus_connection.rs +++ b/gio/src/dbus_connection.rs @@ -11,7 +11,7 @@ use glib::{prelude::*, translate::*}; pub trait DBusMethodCall: Sized { fn parse_call( obj_path: &str, - interface: &str, + interface: Option<&str>, method: &str, params: glib::Variant, ) -> Result; @@ -46,7 +46,7 @@ impl<'a, T: DBusMethodCall> MethodCallBuilder<'a, T> { /// safer interface where the callback returns a result directly. pub fn invoke(self, f: F) -> RegistrationBuilder<'a> where - F: Fn(DBusConnection, &str, T, DBusMethodInvocation) + 'static, + F: Fn(DBusConnection, Option<&str>, T, DBusMethodInvocation) + 'static, { self.registration.method_call( move |connection, sender, obj_path, interface, method, params, invocation| { @@ -74,7 +74,8 @@ impl<'a, T: DBusMethodCall> MethodCallBuilder<'a, T> { /// See [`DBusMethodInvocation::return_result`] for details. pub fn invoke_and_return(self, f: F) -> RegistrationBuilder<'a> where - F: Fn(DBusConnection, &str, T) -> Result, glib::Error> + 'static, + F: Fn(DBusConnection, Option<&str>, T) -> Result, glib::Error> + + 'static, { self.invoke(move |connection, sender, call, invocation| { invocation.return_result(f(connection, sender, call)) @@ -97,7 +98,7 @@ impl<'a, T: DBusMethodCall> MethodCallBuilder<'a, T> { /// See [`DBusMethodInvocation::return_future_local`] for details. pub fn invoke_and_return_future_local(self, f: F) -> RegistrationBuilder<'a> where - F: Fn(DBusConnection, &str, T) -> Fut + 'static, + F: Fn(DBusConnection, Option<&str>, T) -> Fut + 'static, Fut: Future, glib::Error>> + 'static, { self.invoke(move |connection, sender, call, invocation| { @@ -128,18 +129,37 @@ pub struct RegistrationBuilder<'a> { interface_info: &'a DBusInterfaceInfo, #[allow(clippy::type_complexity)] method_call: Option< - Box_, + Box_< + dyn Fn( + DBusConnection, + Option<&str>, + &str, + Option<&str>, + &str, + glib::Variant, + DBusMethodInvocation, + ), + >, >, #[allow(clippy::type_complexity)] - get_property: Option glib::Variant>>, + get_property: + Option, &str, &str, &str) -> glib::Variant>>, #[allow(clippy::type_complexity)] set_property: - Option bool>>, + Option, &str, &str, &str, glib::Variant) -> bool>>, } impl<'a> RegistrationBuilder<'a> { pub fn method_call< - F: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant, DBusMethodInvocation) + 'static, + F: Fn( + DBusConnection, + Option<&str>, + &str, + Option<&str>, + &str, + glib::Variant, + DBusMethodInvocation, + ) + 'static, >( mut self, f: F, @@ -162,7 +182,9 @@ impl<'a> RegistrationBuilder<'a> { } #[doc(alias = "get_property")] - pub fn property glib::Variant + 'static>( + pub fn property< + F: Fn(DBusConnection, Option<&str>, &str, &str, &str) -> glib::Variant + 'static, + >( mut self, f: F, ) -> Self { @@ -171,7 +193,7 @@ impl<'a> RegistrationBuilder<'a> { } pub fn set_property< - F: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant) -> bool + 'static, + F: Fn(DBusConnection, Option<&str>, &str, &str, &str, glib::Variant) -> bool + 'static, >( mut self, f: F, @@ -191,9 +213,9 @@ impl<'a> RegistrationBuilder<'a> { .map(|f| { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); - let sender = args[1].get::<&str>().unwrap(); + let sender = args[1].get::>().unwrap(); let object_path = args[2].get::<&str>().unwrap(); - let interface_name = args[3].get::<&str>().unwrap(); + let interface_name = args[3].get::>().unwrap(); let method_name = args[4].get::<&str>().unwrap(); let parameters = args[5].get::().unwrap(); let invocation = args[6].get::().unwrap(); @@ -215,7 +237,7 @@ impl<'a> RegistrationBuilder<'a> { .map(|f| { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); - let sender = args[1].get::<&str>().unwrap(); + let sender = args[1].get::>().unwrap(); let object_path = args[2].get::<&str>().unwrap(); let interface_name = args[3].get::<&str>().unwrap(); let property_name = args[4].get::<&str>().unwrap(); @@ -237,7 +259,7 @@ impl<'a> RegistrationBuilder<'a> { .map(|f| { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); - let sender = args[1].get::<&str>().unwrap(); + let sender = args[1].get::>().unwrap(); let object_path = args[2].get::<&str>().unwrap(); let interface_name = args[3].get::<&str>().unwrap(); let property_name = args[4].get::<&str>().unwrap(); From 1b67a53fe3eb89e3a8e1118c2533ab8c086f7173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 30 Nov 2024 13:14:22 +0200 Subject: [PATCH 09/23] gio: Add test for DBus method calls over a UNIX fd pair --- gio/tests/dbus_peer.rs | 157 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 gio/tests/dbus_peer.rs diff --git a/gio/tests/dbus_peer.rs b/gio/tests/dbus_peer.rs new file mode 100644 index 000000000000..67e66b35bd90 --- /dev/null +++ b/gio/tests/dbus_peer.rs @@ -0,0 +1,157 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +#[cfg(unix)] +#[test] +fn test_gdbus_peer_connection() { + use gio::{ + glib::{self, VariantTy}, + prelude::*, + DBusConnection, DBusConnectionFlags, DBusNodeInfo, Socket, + }; + use std::os::{fd::IntoRawFd, unix::net::UnixStream}; + + const EXAMPLE_XML: &str = r#" + + + + + + + + +"#; + + pub async fn spawn_server(fd: UnixStream) -> DBusConnection { + let socket = unsafe { Socket::from_fd(fd.into_raw_fd()) }.unwrap(); + let socket_connection = socket.connection_factory_create_connection(); + + let guid = gio::dbus_generate_guid(); + + dbg!("server connecting"); + + let connection = DBusConnection::new_future( + &socket_connection, + Some(&guid), + DBusConnectionFlags::AUTHENTICATION_SERVER + .union(DBusConnectionFlags::DELAY_MESSAGE_PROCESSING), + None, + ) + .await + .unwrap(); + + dbg!("server connected"); + + let interface_info = DBusNodeInfo::for_xml(EXAMPLE_XML) + .unwrap() + .lookup_interface("com.github.gtk_rs") + .unwrap(); + + let _id = connection + .register_object("/com/github/gtk_rs", &interface_info) + .method_call( + |_connection, + _sender, + _object_path, + _interface_name, + _method_name, + parameters, + invocation| { + dbg!( + _sender, + _object_path, + _interface_name, + _method_name, + ¶meters, + &invocation + ); + + let name = parameters.child_get::(0); + invocation.return_value(Some(&(format!("Hello {name}!"),).to_variant())); + }, + ) + .build() + .unwrap(); + + dbg!("server starts message processing"); + + connection.start_message_processing(); + + dbg!("server awaiting calls"); + + connection + } + + pub async fn spawn_client(fd: UnixStream) -> DBusConnection { + let socket_client = unsafe { Socket::from_fd(fd.into_raw_fd()) }.unwrap(); + let socket_connection_client = socket_client.connection_factory_create_connection(); + + dbg!("client connecting"); + + let connection = DBusConnection::new_future( + &socket_connection_client, + None, + DBusConnectionFlags::AUTHENTICATION_CLIENT, + None, + ) + .await + .unwrap(); + + dbg!("client connected"); + + connection + } + + let ctx = glib::MainContext::default(); + + let (x, y) = std::os::unix::net::UnixStream::pair().unwrap(); + + x.set_nonblocking(true).unwrap(); + y.set_nonblocking(true).unwrap(); + + ctx.block_on(async move { + let ctx = glib::MainContext::default(); + + let server = ctx.spawn_local(spawn_server(x)); + let client = ctx.spawn_local(spawn_client(y)); + + let server = server.await.unwrap(); + let client = client.await.unwrap(); + + dbg!("calling method"); + + let result = client + .call_future( + None, + "/com/github/gtk_rs", + "com.github.gtk_rs", + "Hello", + Some(&("World",).into()), + Some(VariantTy::new("(s)").unwrap()), + gio::DBusCallFlags::NONE, + 10000, + ) + .await + .unwrap(); + + dbg!("method called"); + + dbg!(&result); + + dbg!("closing client"); + client.close_future().await.unwrap(); + dbg!("closed client, closing server"); + server.close_future().await.unwrap(); + dbg!("closed server"); + + drop(client); + drop(server); + + assert_eq!(result.child_get::(0), "Hello World!"); + + glib::timeout_future_with_priority( + glib::Priority::LOW, + std::time::Duration::from_millis(50), + ) + .await; + }); +} From 8f8c8b20ebca8ebf41a14674aa8187ebd50de9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 16 Dec 2024 18:49:34 +0200 Subject: [PATCH 10/23] Update gir --- gir | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gir b/gir index e9ef1f366af2..e06125dad46a 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit e9ef1f366af2a54be48d37cff1104a77cd975413 +Subproject commit e06125dad46a08379ad5c1f20c6fb566c68fc657 From 6ddd3aaff345b5a762a1809358b0da8ef05cfa32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 16 Dec 2024 20:00:28 +0200 Subject: [PATCH 11/23] Update gir-files --- gir-files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gir-files b/gir-files index d48ffb674809..01066bc7d926 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit d48ffb674809dba0989cdc3af9a149defe0d3c85 +Subproject commit 01066bc7d926da07306225c810f13ca42cfcf0b6 From 0315a7c541b47132f9726b39b18ca82b1cf0e688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 16 Dec 2024 20:08:24 +0200 Subject: [PATCH 12/23] Regenerate with latest gir / gir-files --- gdk-pixbuf/src/auto/versions.txt | 4 ++-- gdk-pixbuf/sys/versions.txt | 4 ++-- gio/src/auto/dbus_connection.rs | 11 ++++++----- gio/src/auto/dbus_proxy.rs | 11 ++++++----- gio/src/auto/versions.txt | 4 ++-- gio/src/auto/vfs.rs | 28 ++++++++++++++++------------ gio/sys/versions.txt | 4 ++-- glib/gobject-sys/src/lib.rs | 2 +- glib/gobject-sys/versions.txt | 4 ++-- glib/src/auto/constants.rs | 10 ++++++++++ glib/src/auto/mod.rs | 6 ++++++ glib/src/auto/versions.txt | 4 ++-- glib/sys/src/lib.rs | 5 +++++ glib/sys/tests/abi.rs | 2 ++ glib/sys/tests/constant.c | 2 ++ glib/sys/versions.txt | 4 ++-- graphene/src/auto/versions.txt | 4 ++-- graphene/sys/versions.txt | 4 ++-- pango/src/auto/font_map.rs | 20 ++++++++++++++++++++ pango/src/auto/versions.txt | 4 ++-- pango/sys/Cargo.toml | 4 ++++ pango/sys/src/lib.rs | 7 +++++++ pango/sys/versions.txt | 4 ++-- pangocairo/src/auto/versions.txt | 4 ++-- pangocairo/sys/versions.txt | 4 ++-- 25 files changed, 111 insertions(+), 49 deletions(-) diff --git a/gdk-pixbuf/src/auto/versions.txt b/gdk-pixbuf/src/auto/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/gdk-pixbuf/src/auto/versions.txt +++ b/gdk-pixbuf/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/gdk-pixbuf/sys/versions.txt b/gdk-pixbuf/sys/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/gdk-pixbuf/sys/versions.txt +++ b/gdk-pixbuf/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/gio/src/auto/dbus_connection.rs b/gio/src/auto/dbus_connection.rs index 9867d4834418..fdec640a9bea 100644 --- a/gio/src/auto/dbus_connection.rs +++ b/gio/src/auto/dbus_connection.rs @@ -221,7 +221,7 @@ impl DBusConnection { #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_connection_call_with_unix_fd_list")] pub fn call_with_unix_fd_list< - P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, + P: FnOnce(Result<(glib::Variant, Option), glib::Error>) + 'static, >( &self, bus_name: Option<&str>, @@ -249,7 +249,7 @@ impl DBusConnection { let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn call_with_unix_fd_list_trampoline< - P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, + P: FnOnce(Result<(glib::Variant, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, @@ -308,8 +308,9 @@ impl DBusConnection { fd_list: Option<&(impl IsA + Clone + 'static)>, ) -> Pin< Box_< - dyn std::future::Future> - + 'static, + dyn std::future::Future< + Output = Result<(glib::Variant, Option), glib::Error>, + > + 'static, >, > { let bus_name = bus_name.map(ToOwned::to_owned); @@ -356,7 +357,7 @@ impl DBusConnection { timeout_msec: i32, fd_list: Option<&impl IsA>, cancellable: Option<&impl IsA>, - ) -> Result<(glib::Variant, UnixFDList), glib::Error> { + ) -> Result<(glib::Variant, Option), glib::Error> { unsafe { let mut out_fd_list = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); diff --git a/gio/src/auto/dbus_proxy.rs b/gio/src/auto/dbus_proxy.rs index cc626000acd6..065d16a46c2d 100644 --- a/gio/src/auto/dbus_proxy.rs +++ b/gio/src/auto/dbus_proxy.rs @@ -392,7 +392,7 @@ pub trait DBusProxyExt: IsA + sealed::Sealed + 'static { #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list")] fn call_with_unix_fd_list< - P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, + P: FnOnce(Result<(glib::Variant, Option), glib::Error>) + 'static, >( &self, method_name: &str, @@ -416,7 +416,7 @@ pub trait DBusProxyExt: IsA + sealed::Sealed + 'static { let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn call_with_unix_fd_list_trampoline< - P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, + P: FnOnce(Result<(glib::Variant, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, @@ -467,8 +467,9 @@ pub trait DBusProxyExt: IsA + sealed::Sealed + 'static { fd_list: Option<&(impl IsA + Clone + 'static)>, ) -> Pin< Box_< - dyn std::future::Future> - + 'static, + dyn std::future::Future< + Output = Result<(glib::Variant, Option), glib::Error>, + > + 'static, >, > { let method_name = String::from(method_name); @@ -503,7 +504,7 @@ pub trait DBusProxyExt: IsA + sealed::Sealed + 'static { timeout_msec: i32, fd_list: Option<&impl IsA>, cancellable: Option<&impl IsA>, - ) -> Result<(glib::Variant, UnixFDList), glib::Error> { + ) -> Result<(glib::Variant, Option), glib::Error> { unsafe { let mut out_fd_list = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); diff --git a/gio/src/auto/versions.txt b/gio/src/auto/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/gio/src/auto/versions.txt +++ b/gio/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/gio/src/auto/vfs.rs b/gio/src/auto/vfs.rs index c3081f30b4ef..a4a390d2f734 100644 --- a/gio/src/auto/vfs.rs +++ b/gio/src/auto/vfs.rs @@ -92,10 +92,10 @@ pub trait VfsExt: IsA + sealed::Sealed + 'static { fn register_uri_scheme( &self, scheme: &str, - uri_func: Option File + 'static>>, - parse_name_func: Option File + 'static>>, + uri_func: Option Option + 'static>>, + parse_name_func: Option Option + 'static>>, ) -> bool { - let uri_func_data: Box_ File + 'static>>> = + let uri_func_data: Box_ Option + 'static>>> = Box_::new(uri_func); unsafe extern "C" fn uri_func_func( vfs: *mut ffi::GVfs, @@ -104,7 +104,8 @@ pub trait VfsExt: IsA + sealed::Sealed + 'static { ) -> *mut ffi::GFile { let vfs = from_glib_borrow(vfs); let identifier: Borrowed = from_glib_borrow(identifier); - let callback = &*(user_data as *mut Option File + 'static>>); + let callback = + &*(user_data as *mut Option Option + 'static>>); if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { @@ -117,7 +118,7 @@ pub trait VfsExt: IsA + sealed::Sealed + 'static { } else { None }; - let parse_name_func_data: Box_ File + 'static>>> = + let parse_name_func_data: Box_ Option + 'static>>> = Box_::new(parse_name_func); unsafe extern "C" fn parse_name_func_func( vfs: *mut ffi::GVfs, @@ -126,7 +127,8 @@ pub trait VfsExt: IsA + sealed::Sealed + 'static { ) -> *mut ffi::GFile { let vfs = from_glib_borrow(vfs); let identifier: Borrowed = from_glib_borrow(identifier); - let callback = &*(user_data as *mut Option File + 'static>>); + let callback = + &*(user_data as *mut Option Option + 'static>>); if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { @@ -140,18 +142,20 @@ pub trait VfsExt: IsA + sealed::Sealed + 'static { None }; unsafe extern "C" fn uri_destroy_func(data: glib::ffi::gpointer) { - let _callback = - Box_::from_raw(data as *mut Option File + 'static>>); + let _callback = Box_::from_raw( + data as *mut Option Option + 'static>>, + ); } let destroy_call4 = Some(uri_destroy_func as _); unsafe extern "C" fn parse_name_destroy_func(data: glib::ffi::gpointer) { - let _callback = - Box_::from_raw(data as *mut Option File + 'static>>); + let _callback = Box_::from_raw( + data as *mut Option Option + 'static>>, + ); } let destroy_call7 = Some(parse_name_destroy_func as _); - let super_callback0: Box_ File + 'static>>> = + let super_callback0: Box_ Option + 'static>>> = uri_func_data; - let super_callback1: Box_ File + 'static>>> = + let super_callback1: Box_ Option + 'static>>> = parse_name_func_data; unsafe { from_glib(ffi::g_vfs_register_uri_scheme( diff --git a/gio/sys/versions.txt b/gio/sys/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/gio/sys/versions.txt +++ b/gio/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/glib/gobject-sys/src/lib.rs b/glib/gobject-sys/src/lib.rs index 658a5bd2025c..56ee48133713 100644 --- a/glib/gobject-sys/src/lib.rs +++ b/glib/gobject-sys/src/lib.rs @@ -1929,10 +1929,10 @@ extern "C" { //========================================================================= // GWeakRef //========================================================================= + pub fn g_weak_ref_set(weak_ref: *mut GWeakRef, object: *mut GObject); pub fn g_weak_ref_clear(weak_ref: *mut GWeakRef); pub fn g_weak_ref_get(weak_ref: *mut GWeakRef) -> *mut GObject; pub fn g_weak_ref_init(weak_ref: *mut GWeakRef, object: *mut GObject); - pub fn g_weak_ref_set(weak_ref: *mut GWeakRef, object: *mut GObject); //========================================================================= // GBinding diff --git a/glib/gobject-sys/versions.txt b/glib/gobject-sys/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/glib/gobject-sys/versions.txt +++ b/glib/gobject-sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/glib/src/auto/constants.rs b/glib/src/auto/constants.rs index a1da875b5225..2f2127d21d00 100644 --- a/glib/src/auto/constants.rs +++ b/glib/src/auto/constants.rs @@ -96,6 +96,16 @@ pub static STR_DELIMITERS: &GStr = #[doc(alias = "G_TEST_OPTION_ISOLATE_DIRS")] pub static TEST_OPTION_ISOLATE_DIRS: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_TEST_OPTION_ISOLATE_DIRS) }; +#[cfg(feature = "v2_84")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] +#[doc(alias = "G_TEST_OPTION_NONFATAL_ASSERTIONS")] +pub static TEST_OPTION_NONFATAL_ASSERTIONS: &GStr = + unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_TEST_OPTION_NONFATAL_ASSERTIONS) }; +#[cfg(feature = "v2_84")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] +#[doc(alias = "G_TEST_OPTION_NO_PRGNAME")] +pub static TEST_OPTION_NO_PRGNAME: &GStr = + unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_TEST_OPTION_NO_PRGNAME) }; #[doc(alias = "G_URI_RESERVED_CHARS_GENERIC_DELIMITERS")] pub static URI_RESERVED_CHARS_GENERIC_DELIMITERS: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_URI_RESERVED_CHARS_GENERIC_DELIMITERS) }; diff --git a/glib/src/auto/mod.rs b/glib/src/auto/mod.rs index 0330de419bf6..d730bfb4e092 100644 --- a/glib/src/auto/mod.rs +++ b/glib/src/auto/mod.rs @@ -124,5 +124,11 @@ pub use self::constants::STR_DELIMITERS; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] pub use self::constants::TEST_OPTION_ISOLATE_DIRS; +#[cfg(feature = "v2_84")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] +pub use self::constants::TEST_OPTION_NONFATAL_ASSERTIONS; +#[cfg(feature = "v2_84")] +#[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] +pub use self::constants::TEST_OPTION_NO_PRGNAME; pub use self::constants::URI_RESERVED_CHARS_GENERIC_DELIMITERS; pub use self::constants::URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS; diff --git a/glib/src/auto/versions.txt b/glib/src/auto/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/glib/src/auto/versions.txt +++ b/glib/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/glib/sys/src/lib.rs b/glib/sys/src/lib.rs index e207581dbf10..8fd7ad5c4460 100644 --- a/glib/sys/src/lib.rs +++ b/glib/sys/src/lib.rs @@ -794,6 +794,8 @@ pub const GLIB_SYSDEF_MSG_DONTROUTE: c_int = 4; pub const GLIB_SYSDEF_MSG_OOB: c_int = 1; pub const GLIB_SYSDEF_MSG_PEEK: c_int = 2; pub const G_TEST_OPTION_ISOLATE_DIRS: &[u8] = b"isolate_dirs\0"; +pub const G_TEST_OPTION_NONFATAL_ASSERTIONS: &[u8] = b"nonfatal-assertions\0"; +pub const G_TEST_OPTION_NO_PRGNAME: &[u8] = b"no_g_set_prgname\0"; pub const G_TIME_SPAN_DAY: i64 = 86400000000; pub const G_TIME_SPAN_HOUR: i64 = 3600000000; pub const G_TIME_SPAN_MILLISECOND: i64 = 1000; @@ -5369,6 +5371,9 @@ extern "C" { data: gpointer, error: *mut *mut GError, ) -> *mut GThread; + #[cfg(feature = "v2_84")] + #[cfg_attr(docsrs, doc(cfg(feature = "v2_84")))] + pub fn g_thread_get_name(thread: *mut GThread) -> *const c_char; pub fn g_thread_join(thread: *mut GThread) -> gpointer; pub fn g_thread_ref(thread: *mut GThread) -> *mut GThread; pub fn g_thread_set_priority(thread: *mut GThread, priority: GThreadPriority); diff --git a/glib/sys/tests/abi.rs b/glib/sys/tests/abi.rs index b1937208bacb..b4a3a972ec5f 100644 --- a/glib/sys/tests/abi.rs +++ b/glib/sys/tests/abi.rs @@ -1488,6 +1488,8 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("(gint) G_TEST_LOG_STOP_CASE", "6"), ("(gint) G_TEST_LOG_STOP_SUITE", "11"), ("G_TEST_OPTION_ISOLATE_DIRS", "isolate_dirs"), + ("G_TEST_OPTION_NONFATAL_ASSERTIONS", "nonfatal-assertions"), + ("G_TEST_OPTION_NO_PRGNAME", "no_g_set_prgname"), ("(gint) G_TEST_RUN_FAILURE", "2"), ("(gint) G_TEST_RUN_INCOMPLETE", "3"), ("(gint) G_TEST_RUN_SKIPPED", "1"), diff --git a/glib/sys/tests/constant.c b/glib/sys/tests/constant.c index bea4e15a5718..8dad5595f053 100644 --- a/glib/sys/tests/constant.c +++ b/glib/sys/tests/constant.c @@ -469,6 +469,8 @@ int main() { PRINT_CONSTANT((gint) G_TEST_LOG_STOP_CASE); PRINT_CONSTANT((gint) G_TEST_LOG_STOP_SUITE); PRINT_CONSTANT(G_TEST_OPTION_ISOLATE_DIRS); + PRINT_CONSTANT(G_TEST_OPTION_NONFATAL_ASSERTIONS); + PRINT_CONSTANT(G_TEST_OPTION_NO_PRGNAME); PRINT_CONSTANT((gint) G_TEST_RUN_FAILURE); PRINT_CONSTANT((gint) G_TEST_RUN_INCOMPLETE); PRINT_CONSTANT((gint) G_TEST_RUN_SKIPPED); diff --git a/glib/sys/versions.txt b/glib/sys/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/glib/sys/versions.txt +++ b/glib/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/graphene/src/auto/versions.txt b/graphene/src/auto/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/graphene/src/auto/versions.txt +++ b/graphene/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/graphene/sys/versions.txt b/graphene/sys/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/graphene/sys/versions.txt +++ b/graphene/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/pango/src/auto/font_map.rs b/pango/src/auto/font_map.rs index c2c01d44c785..45f1f266d08e 100644 --- a/pango/src/auto/font_map.rs +++ b/pango/src/auto/font_map.rs @@ -24,6 +24,26 @@ mod sealed { } pub trait FontMapExt: IsA + sealed::Sealed + 'static { + #[cfg(feature = "v1_56")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_56")))] + #[doc(alias = "pango_font_map_add_font_file")] + fn add_font_file(&self, filename: impl AsRef) -> Result<(), glib::Error> { + unsafe { + let mut error = std::ptr::null_mut(); + let is_ok = ffi::pango_font_map_add_font_file( + self.as_ref().to_glib_none().0, + filename.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 = "pango_font_map_changed")] fn changed(&self) { unsafe { diff --git a/pango/src/auto/versions.txt b/pango/src/auto/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/pango/src/auto/versions.txt +++ b/pango/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/pango/sys/Cargo.toml b/pango/sys/Cargo.toml index c362c7c90dd1..133f097ac7cc 100644 --- a/pango/sys/Cargo.toml +++ b/pango/sys/Cargo.toml @@ -22,6 +22,7 @@ v1_48 = ["v1_46"] v1_50 = ["v1_48"] v1_52 = ["v1_50"] v1_54 = ["v1_52"] +v1_56 = ["v1_54"] [lib] name = "pango_sys" @@ -81,6 +82,9 @@ version = "1.52" [package.metadata.system-deps.pango.v1_54] version = "1.53" +[package.metadata.system-deps.pango.v1_56] +version = "1.56" + [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] diff --git a/pango/sys/src/lib.rs b/pango/sys/src/lib.rs index 71b819c3d767..87b551ac3a66 100644 --- a/pango/sys/src/lib.rs +++ b/pango/sys/src/lib.rs @@ -2399,6 +2399,13 @@ extern "C" { // PangoFontMap //========================================================================= pub fn pango_font_map_get_type() -> GType; + #[cfg(feature = "v1_56")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_56")))] + pub fn pango_font_map_add_font_file( + fontmap: *mut PangoFontMap, + filename: *const c_char, + error: *mut *mut glib::GError, + ) -> gboolean; pub fn pango_font_map_changed(fontmap: *mut PangoFontMap); pub fn pango_font_map_create_context(fontmap: *mut PangoFontMap) -> *mut PangoContext; #[cfg(feature = "v1_46")] diff --git a/pango/sys/versions.txt b/pango/sys/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/pango/sys/versions.txt +++ b/pango/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/pangocairo/src/auto/versions.txt b/pangocairo/src/auto/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/pangocairo/src/auto/versions.txt +++ b/pangocairo/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) diff --git a/pangocairo/sys/versions.txt b/pangocairo/sys/versions.txt index 2bf5373b57cc..bba14f1d708d 100644 --- a/pangocairo/sys/versions.txt +++ b/pangocairo/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ e9ef1f366af2) -from gir-files (https://github.com/gtk-rs/gir-files @ d48ffb674809) +Generated by gir (https://github.com/gtk-rs/gir @ e06125dad46a) +from gir-files (https://github.com/gtk-rs/gir-files @ 01066bc7d926) From dfc6751379326348cdd1e85076c2bc397fa5c294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 22 Nov 2024 14:25:55 +0200 Subject: [PATCH 13/23] ci: Check pango 1.56 feature on the CI --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index dd97c7edb128..141e918e331d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -25,7 +25,7 @@ jobs: - { name: "gio", features: "v2_84", nightly: "--all-features", test_sys: true } - { name: "glib", features: "v2_84,log", nightly: "--all-features", test_sys: true } - { name: "graphene", features: "", nightly: "", test_sys: true } - - { name: "pango", features: "v1_54", nightly: "--all-features", test_sys: true } + - { name: "pango", features: "v1_56", nightly: "--all-features", test_sys: true } - { name: "pangocairo", features: "", nightly: "--all-features", test_sys: true } steps: - uses: actions/checkout@v4 From 0fcb436aa61b9c549ac21e30aa26e360e4f278ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 22 Nov 2024 14:26:23 +0200 Subject: [PATCH 14/23] pango: Update C library version requirements --- pango/Cargo.toml | 1 + pango/sys/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pango/Cargo.toml b/pango/Cargo.toml index 83ae9c5d3e39..3a26581f880c 100644 --- a/pango/Cargo.toml +++ b/pango/Cargo.toml @@ -21,6 +21,7 @@ v1_48 = ["v1_46", "pango-sys/v1_48"] v1_50 = ["v1_48", "pango-sys/v1_50"] v1_52 = ["v1_50", "pango-sys/v1_52"] v1_54 = ["v1_52", "pango-sys/v1_54"] +v1_56 = ["v1_54", "pango-sys/v1_56"] [dependencies] pango-sys.workspace = true diff --git a/pango/sys/Cargo.toml b/pango/sys/Cargo.toml index 133f097ac7cc..4a28ec8b5d9c 100644 --- a/pango/sys/Cargo.toml +++ b/pango/sys/Cargo.toml @@ -80,10 +80,10 @@ version = "1.50" version = "1.52" [package.metadata.system-deps.pango.v1_54] -version = "1.53" +version = "1.54" [package.metadata.system-deps.pango.v1_56] -version = "1.56" +version = "1.55" [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] From c869b0bdb042f4cb9a62384a37fc560663828b0f Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sun, 1 Dec 2024 13:06:13 +0100 Subject: [PATCH 15/23] 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 | 131 ++++ gio/src/auto/dbus_object_proxy.rs | 58 ++ gio/src/auto/dbus_object_skeleton.rs | 162 ++++ gio/src/auto/dtls_client_connection.rs | 192 +++++ gio/src/auto/dtls_connection.rs | 854 +++++++++++++++++++++ gio/src/auto/dtls_server_connection.rs | 89 +++ 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 | 84 ++ gio/src/auto/tcp_wrapper_connection.rs | 53 ++ gio/src/auto/test_dbus.rs | 69 ++ gio/src/auto/unix_connection.rs | 241 ++++++ gio/src/auto/unix_mount_monitor.rs | 71 ++ 17 files changed, 3183 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..fe4396fff616 --- /dev/null +++ b/gio/src/auto/dbus_object_manager_server.rs @@ -0,0 +1,131 @@ +// 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, + )) + } + } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait DBusObjectManagerServerExt: + IsA + sealed::Sealed + '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..43300def4893 --- /dev/null +++ b/gio/src/auto/dbus_object_proxy.rs @@ -0,0 +1,58 @@ +// 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, + )) + } + } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait DBusObjectProxyExt: IsA + sealed::Sealed + '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..0eb406031839 --- /dev/null +++ b/gio/src/auto/dbus_object_skeleton.rs @@ -0,0 +1,162 @@ +// 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, + )) + } + } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait DBusObjectSkeletonExt: IsA + sealed::Sealed + '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..138ab0b9c8f5 --- /dev/null +++ b/gio/src/auto/dtls_client_connection.rs @@ -0,0 +1,192 @@ +// 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)) + } + } + } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait DtlsClientConnectionExt: IsA + sealed::Sealed + '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..e40a14193f02 --- /dev/null +++ b/gio/src/auto/dtls_connection.rs @@ -0,0 +1,854 @@ +// 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; +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait DtlsConnectionExt: IsA + sealed::Sealed + '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..2500a49dd45e --- /dev/null +++ b/gio/src/auto/dtls_server_connection.rs @@ -0,0 +1,89 @@ +// 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)) + } + } + } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait DtlsServerConnectionExt: IsA + sealed::Sealed + '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..cfcb71b909e3 --- /dev/null +++ b/gio/src/auto/proxy_address_enumerator.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, 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; +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait ProxyAddressEnumeratorExt: + IsA + sealed::Sealed + '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..93da8bcc950e --- /dev/null +++ b/gio/src/auto/tcp_wrapper_connection.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, 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() + } + } +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait TcpWrapperConnectionExt: IsA + sealed::Sealed + '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..e579a88fabf8 --- /dev/null +++ b/gio/src/auto/unix_connection.rs @@ -0,0 +1,241 @@ +// 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; +} + +mod sealed { + pub trait Sealed {} + impl> Sealed for T {} +} + +pub trait UnixConnectionExt: IsA + sealed::Sealed + '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), + ) + } + } +} From c49d4d65d28f18003d41ea9f1db8eac203aca493 Mon Sep 17 00:00:00 2001 From: Paolo Borelli Date: Mon, 9 Dec 2024 14:39:40 +0100 Subject: [PATCH 16/23] windows: use a range for windows-rs dependency Leave it up to the consumer to determine the specific version. --- cairo/sys/Cargo.toml | 2 +- gio/sys/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cairo/sys/Cargo.toml b/cairo/sys/Cargo.toml index 32fd8297670b..b40f1c530e4c 100644 --- a/cairo/sys/Cargo.toml +++ b/cairo/sys/Cargo.toml @@ -63,7 +63,7 @@ version = "2.16" features = ["xlib"] [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.52", features = ["Win32_Graphics_Gdi"], optional = true } +windows-sys = { version = ">=0.52, <=0.59", features = ["Win32_Graphics_Gdi"], optional = true } [build-dependencies] system-deps = "7" diff --git a/gio/sys/Cargo.toml b/gio/sys/Cargo.toml index 9a2f11a5ff2b..77e007f993f9 100644 --- a/gio/sys/Cargo.toml +++ b/gio/sys/Cargo.toml @@ -11,7 +11,7 @@ workspace = true workspace = true [target."cfg(windows)".dependencies.windows-sys] -version = "0.52" +version = ">=0.52, <=0.59" features = ["Win32_Networking_WinSock"] [dev-dependencies] From 8be11f248e0ab8a7f3f35b2964c7c8cd616119af Mon Sep 17 00:00:00 2001 From: Paolo Borelli Date: Mon, 9 Dec 2024 14:43:19 +0100 Subject: [PATCH 17/23] ci: bump gvsbuild version --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 7090d8889e43..e9a9c788cff3 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -14,7 +14,7 @@ jobs: env: # git revision of gvsbuild we use for to build GLib and the other dependencies - gvsbuildref: bb1d2691d25c7bb1239118a907c8e21b1aa24e03 + gvsbuildref: 230e1074047b9654b76217c5d48b10c726fbe0f6 # bump this number if you want to force a rebuild of gvsbuild with the same revision gvsbuildupdate: 1 From a806de502757fc1b1a2dd4c147ea54c9640c68de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Dec 2024 10:06:42 +0200 Subject: [PATCH 18/23] gio: Export `RegistrationBuilder` from the crate root It was not exported at all before. Fixes https://github.com/gtk-rs/gtk-rs-core/issues/1597 --- gio/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gio/src/lib.rs b/gio/src/lib.rs index b559db77329d..c15f62b8cf1f 100644 --- a/gio/src/lib.rs +++ b/gio/src/lib.rs @@ -28,8 +28,8 @@ mod dbus; pub use self::dbus::*; mod dbus_connection; pub use self::dbus_connection::{ - ActionGroupExportId, FilterId, MenuModelExportId, RegistrationId, SignalSubscriptionId, - WatcherId, + ActionGroupExportId, FilterId, MenuModelExportId, RegistrationBuilder, RegistrationId, + SignalSubscriptionId, WatcherId, }; mod dbus_message; mod dbus_method_invocation; From 99b17222a031206cc803dfa37cacd421164bbc29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Dec 2024 19:21:09 +0200 Subject: [PATCH 19/23] gio: Work around GLib memory leak in g_dbus_connection_register_object_with_closures() Assume that the invocation is passed as `transfer full` into the closure. This workaround is not going to break with future versions of GLib as fixing the bug was considered a breaking API change. See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4427 --- gio/src/dbus_connection.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gio/src/dbus_connection.rs b/gio/src/dbus_connection.rs index 2e46f9bc3279..aaf26e5e7c07 100644 --- a/gio/src/dbus_connection.rs +++ b/gio/src/dbus_connection.rs @@ -218,7 +218,19 @@ impl<'a> RegistrationBuilder<'a> { let interface_name = args[3].get::>().unwrap(); let method_name = args[4].get::<&str>().unwrap(); let parameters = args[5].get::().unwrap(); - let invocation = args[6].get::().unwrap(); + + // Work around GLib memory leak: Assume that the invocation is passed + // as `transfer full` into the closure. + // + // This workaround is not going to break with future versions of + // GLib as fixing the bug was considered a breaking API change. + // + // See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4427 + let invocation = from_glib_full(glib::gobject_ffi::g_value_get_object( + args[6].as_ptr(), + ) + as *mut ffi::GDBusMethodInvocation); + f( conn, sender, From bb8bae2773ad95498ae8f9980e52268ba88457f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 16 Dec 2024 20:25:50 +0200 Subject: [PATCH 20/23] Update Cargo.lock --- Cargo.lock | 130 ++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 75476c3ffc98..41434f8d2f1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ "glib-sys", "libc", "system-deps", - "windows-sys 0.52.0", + "windows-sys 0.59.0", "x11", ] @@ -102,18 +102,18 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.37" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" dependencies = [ "shlex", ] [[package]] name = "cfg-expr" -version = "0.17.0" +version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0890061c4d3223e7267f3bad2ec40b997d64faac1c2815a4a9d95018e2b9e9c" +checksum = "8d4ba6e40bd1184518716a6e1a781bf9160e286d219ccdb8ab2612e74cfe4789" dependencies = [ "smallvec", "target-lexicon", @@ -215,9 +215,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ "crossbeam-epoch", "crossbeam-utils", @@ -234,9 +234,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.20" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "crunchy" @@ -258,19 +258,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "float_eq" @@ -452,7 +452,7 @@ dependencies = [ "shell-words", "system-deps", "tempfile", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -579,9 +579,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "heck" @@ -597,9 +597,9 @@ checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -627,24 +627,25 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] [[package]] name = "libc" -version = "0.2.162" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "linux-raw-sys" @@ -823,9 +824,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -861,9 +862,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ "bitflags", ] @@ -882,9 +883,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -929,15 +930,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.39" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -978,9 +979,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.2.4" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d25269dd3a12467afe2e510f69fb0b46b698e5afb296b59f2145259deaf8e8" +checksum = "94b13f8ea6177672c49d12ed964cca44836f59621981b04a3e26b87e675181de" dependencies = [ "sdd", ] @@ -1003,24 +1004,24 @@ dependencies = [ [[package]] name = "sdd" -version = "3.0.4" +version = "3.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49c1eeaf4b6a87c7479688c6d52b9f1153cedd3c489300564f932b065c6eab95" +checksum = "478f121bb72bbf63c52c93011ea1791dca40140dfe13f8336c4c5ac952c33aa9" [[package]] name = "serde" -version = "1.0.214" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -1029,9 +1030,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -1050,9 +1051,9 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" dependencies = [ "futures", "log", @@ -1064,9 +1065,9 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "3.1.1" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", @@ -1114,9 +1115,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -1225,9 +1226,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "untrusted" @@ -1265,9 +1266,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -1276,13 +1277,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -1291,9 +1291,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1301,9 +1301,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -1314,15 +1314,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", From 660d48fbe5042952767a2e5995eb0d2aa3276619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 22 Nov 2024 14:27:08 +0200 Subject: [PATCH 21/23] deny: Update unicode license name --- deny.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deny.toml b/deny.toml index 0901823f724a..b9b13f8b9083 100644 --- a/deny.toml +++ b/deny.toml @@ -15,7 +15,7 @@ allow = [ "MIT", "Apache-2.0", "Apache-2.0 WITH LLVM-exception", - "Unicode-DFS-2016", + "Unicode-3.0", ] confidence-threshold = 0.8 From b5ec976ab14d70ea8f1f288dbdbd5ce9cf21993d Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 31 Oct 2024 14:24:45 +0100 Subject: [PATCH 22/23] Fix new beta clippy warnings --- cairo/src/device.rs | 2 +- cairo/src/image_surface.rs | 10 +++--- cairo/src/paths.rs | 4 +-- gio/src/inet_address.rs | 2 +- gio/src/list_model.rs | 11 +++---- gio/src/settings.rs | 2 +- gio/src/socket.rs | 14 ++++---- gio/src/unix_fd_list.rs | 2 +- gio/src/unix_socket_address.rs | 2 +- glib-macros/src/clone.rs | 2 +- glib/src/collections/list.rs | 4 +-- glib/src/collections/ptr_slice.rs | 4 +-- glib/src/collections/slist.rs | 4 +-- glib/src/collections/strv.rs | 54 +++++++++++++++---------------- glib/src/enums.rs | 6 ++-- glib/src/gstring.rs | 2 +- glib/src/main_context.rs | 6 ++-- glib/src/match_info.rs | 20 ++++++------ glib/src/object.rs | 36 ++++++++++----------- glib/src/translate.rs | 4 +-- glib/src/types.rs | 6 ++-- glib/src/value.rs | 12 ++++--- glib/src/variant.rs | 4 +-- glib/src/variant_iter.rs | 4 +-- glib/src/variant_type.rs | 2 +- glib/src/wrapper.rs | 1 - pango/src/attr_iterator.rs | 14 ++++---- pango/src/glyph_item_iter.rs | 6 ++-- pango/src/script_iter.rs | 10 +++--- 29 files changed, 124 insertions(+), 126 deletions(-) diff --git a/cairo/src/device.rs b/cairo/src/device.rs index 34400e5e7dbc..c35069396561 100644 --- a/cairo/src/device.rs +++ b/cairo/src/device.rs @@ -19,7 +19,7 @@ use crate::{Content, RecordingSurface, ScriptMode, Surface}; #[must_use = "if unused the Device will immediately be released"] pub struct DeviceAcquireGuard<'a>(&'a Device); -impl<'a> Drop for DeviceAcquireGuard<'a> { +impl Drop for DeviceAcquireGuard<'_> { #[inline] fn drop(&mut self) { self.0.release(); diff --git a/cairo/src/image_surface.rs b/cairo/src/image_surface.rs index 15c1cc7395d9..1c50e00990ab 100644 --- a/cairo/src/image_surface.rs +++ b/cairo/src/image_surface.rs @@ -234,8 +234,8 @@ pub struct ImageSurfaceData<'a> { dirty: bool, } -unsafe impl<'a> Send for ImageSurfaceData<'a> {} -unsafe impl<'a> Sync for ImageSurfaceData<'a> {} +unsafe impl Send for ImageSurfaceData<'_> {} +unsafe impl Sync for ImageSurfaceData<'_> {} impl<'a> ImageSurfaceData<'a> { fn new(surface: &'a mut ImageSurface) -> ImageSurfaceData<'a> { @@ -255,7 +255,7 @@ impl<'a> ImageSurfaceData<'a> { } } -impl<'a> Drop for ImageSurfaceData<'a> { +impl Drop for ImageSurfaceData<'_> { #[inline] fn drop(&mut self) { if self.dirty { @@ -264,7 +264,7 @@ impl<'a> Drop for ImageSurfaceData<'a> { } } -impl<'a> Deref for ImageSurfaceData<'a> { +impl Deref for ImageSurfaceData<'_> { type Target = [u8]; #[inline] @@ -273,7 +273,7 @@ impl<'a> Deref for ImageSurfaceData<'a> { } } -impl<'a> DerefMut for ImageSurfaceData<'a> { +impl DerefMut for ImageSurfaceData<'_> { #[inline] fn deref_mut(&mut self) -> &mut [u8] { self.dirty = true; diff --git a/cairo/src/paths.rs b/cairo/src/paths.rs index 65b2e9dfe808..f870d3165905 100644 --- a/cairo/src/paths.rs +++ b/cairo/src/paths.rs @@ -65,7 +65,7 @@ pub struct PathSegments<'a> { num_data: usize, } -impl<'a> Iterator for PathSegments<'a> { +impl Iterator for PathSegments<'_> { type Item = PathSegment; fn next(&mut self) -> Option { @@ -93,7 +93,7 @@ impl<'a> Iterator for PathSegments<'a> { } } -impl<'a> FusedIterator for PathSegments<'a> {} +impl FusedIterator for PathSegments<'_> {} fn to_tuple(pair: &[f64; 2]) -> (f64, f64) { (pair[0], pair[1]) diff --git a/gio/src/inet_address.rs b/gio/src/inet_address.rs index e5d413accf98..ddf6d710cd75 100644 --- a/gio/src/inet_address.rs +++ b/gio/src/inet_address.rs @@ -12,7 +12,7 @@ pub enum InetAddressBytes<'a> { V6(&'a [u8; 16]), } -impl<'a> InetAddressBytes<'a> { +impl InetAddressBytes<'_> { #[inline] fn deref(&self) -> &[u8] { use self::InetAddressBytes::*; diff --git a/gio/src/list_model.rs b/gio/src/list_model.rs index 5eaa3caa8cd2..480db7807c56 100644 --- a/gio/src/list_model.rs +++ b/gio/src/list_model.rs @@ -31,7 +31,6 @@ pub trait ListModelExtManual: sealed::Sealed + IsA + Sized { /// # Panics /// /// Panics if `T::static_type().is_a(self.item_type())` is not true. - fn iter>(&self) -> ListModelIter { assert!(self.item_type().is_a(LT::static_type())); @@ -85,7 +84,7 @@ pub struct ListModelIter<'a, T: IsA> { changed: Rc>, signal_id: Option, } -impl<'a, T: IsA> Iterator for ListModelIter<'a, T> { +impl> Iterator for ListModelIter<'_, T> { type Item = Result; fn next(&mut self) -> Option { @@ -144,11 +143,11 @@ impl<'a, T: IsA> Iterator for ListModelIter<'a, T> { } } -impl<'a, T: IsA> FusedIterator for ListModelIter<'a, T> {} +impl> FusedIterator for ListModelIter<'_, T> {} -impl<'a, T: IsA> ExactSizeIterator for ListModelIter<'a, T> {} +impl> ExactSizeIterator for ListModelIter<'_, T> {} -impl<'a, T: IsA> DoubleEndedIterator for ListModelIter<'a, T> { +impl> DoubleEndedIterator for ListModelIter<'_, T> { fn next_back(&mut self) -> Option { if self.reverse_pos == self.i { return None; @@ -183,7 +182,7 @@ impl<'a, T: IsA> DoubleEndedIterator for ListModelIter<'a, T> { } } } -impl<'a, T: IsA> Drop for ListModelIter<'a, T> { +impl> Drop for ListModelIter<'_, T> { #[inline] fn drop(&mut self) { self.model.disconnect(self.signal_id.take().unwrap()); diff --git a/gio/src/settings.rs b/gio/src/settings.rs index d0eda98f65d6..9584e5e0bc86 100644 --- a/gio/src/settings.rs +++ b/gio/src/settings.rs @@ -17,7 +17,7 @@ pub struct BindingBuilder<'a> { set_mapping: Option Option>>, } -impl<'a> BindingBuilder<'a> { +impl BindingBuilder<'_> { pub fn flags(mut self, flags: SettingsBindFlags) -> Self { self.flags = flags; self diff --git a/gio/src/socket.rs b/gio/src/socket.rs index 9662b80ad74c..7b23aaaf9479 100644 --- a/gio/src/socket.rs +++ b/gio/src/socket.rs @@ -81,10 +81,10 @@ impl<'v> InputVector<'v> { } } -unsafe impl<'v> Send for InputVector<'v> {} -unsafe impl<'v> Sync for InputVector<'v> {} +unsafe impl Send for InputVector<'_> {} +unsafe impl Sync for InputVector<'_> {} -impl<'v> std::ops::Deref for InputVector<'v> { +impl std::ops::Deref for InputVector<'_> { type Target = [u8]; #[inline] @@ -93,7 +93,7 @@ impl<'v> std::ops::Deref for InputVector<'v> { } } -impl<'v> std::ops::DerefMut for InputVector<'v> { +impl std::ops::DerefMut for InputVector<'_> { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { unsafe { std::slice::from_raw_parts_mut(self.vector.buffer as *mut _, self.vector.size) } @@ -230,10 +230,10 @@ impl<'v> OutputVector<'v> { } } -unsafe impl<'v> Send for OutputVector<'v> {} -unsafe impl<'v> Sync for OutputVector<'v> {} +unsafe impl Send for OutputVector<'_> {} +unsafe impl Sync for OutputVector<'_> {} -impl<'v> std::ops::Deref for OutputVector<'v> { +impl std::ops::Deref for OutputVector<'_> { type Target = [u8]; #[inline] diff --git a/gio/src/unix_fd_list.rs b/gio/src/unix_fd_list.rs index f6c77515e240..5a702a463026 100644 --- a/gio/src/unix_fd_list.rs +++ b/gio/src/unix_fd_list.rs @@ -60,7 +60,6 @@ pub trait UnixFDListExtManual: sealed::Sealed + IsA + Sized { } #[doc(alias = "g_unix_fd_list_peek_fds")] - fn peek_fds(&self) -> Vec { unsafe { let mut length = mem::MaybeUninit::uninit(); @@ -71,6 +70,7 @@ pub trait UnixFDListExtManual: sealed::Sealed + IsA + Sized { ret } } + #[doc(alias = "g_unix_fd_list_steal_fds")] fn steal_fds(&self) -> Vec { unsafe { diff --git a/gio/src/unix_socket_address.rs b/gio/src/unix_socket_address.rs index 6b17fcadec96..48779e6403d7 100644 --- a/gio/src/unix_socket_address.rs +++ b/gio/src/unix_socket_address.rs @@ -19,7 +19,7 @@ pub enum UnixSocketAddressPath<'a> { AbstractPadded(&'a [u8]), } -impl<'a> UnixSocketAddressPath<'a> { +impl UnixSocketAddressPath<'_> { fn to_type(&self) -> UnixSocketAddressType { use self::UnixSocketAddressPath::*; diff --git a/glib-macros/src/clone.rs b/glib-macros/src/clone.rs index 16bf8a669a7f..9d375fd8702f 100644 --- a/glib-macros/src/clone.rs +++ b/glib-macros/src/clone.rs @@ -19,7 +19,7 @@ pub(crate) enum CaptureKind { ToOwned, } -impl<'a> TryFrom<&'a Ident> for CaptureKind { +impl TryFrom<&'_ Ident> for CaptureKind { type Error = syn::Error; fn try_from(s: &Ident) -> Result { diff --git a/glib/src/collections/list.rs b/glib/src/collections/list.rs index 18845a80f7e6..c2c8096d72fa 100644 --- a/glib/src/collections/list.rs +++ b/glib/src/collections/list.rs @@ -666,7 +666,7 @@ impl<'a, T: TransparentPtrType> Iterator for Iter<'a, T> { } } -impl<'a, T: TransparentPtrType> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} // rustdoc-stripper-ignore-next /// A non-destructive iterator over a [`List`]. @@ -708,7 +708,7 @@ impl<'a, T: TransparentPtrType> Iterator for IterMut<'a, T> { } } -impl<'a, T: TransparentPtrType> FusedIterator for IterMut<'a, T> {} +impl FusedIterator for IterMut<'_, T> {} // rustdoc-stripper-ignore-next /// A destructive iterator over a [`List`]. diff --git a/glib/src/collections/ptr_slice.rs b/glib/src/collections/ptr_slice.rs index 4c19b0655ad5..62d2653e34c3 100644 --- a/glib/src/collections/ptr_slice.rs +++ b/glib/src/collections/ptr_slice.rs @@ -1097,7 +1097,7 @@ impl IntoPtrSlice for PtrSlice { } } -impl<'a, T: TransparentPtrType> IntoPtrSlice for &'a PtrSlice { +impl IntoPtrSlice for &'_ PtrSlice { #[inline] fn run_with_ptr_slice::GlibType]) -> R>(self, f: F) -> R { f(unsafe { std::slice::from_raw_parts(self.as_ptr() as *mut _, self.len() + 1) }) @@ -1160,7 +1160,7 @@ impl IntoPtrSlice for [T; N] { } } -impl<'a, T: TransparentPtrType> IntoPtrSlice for &'a [T] { +impl IntoPtrSlice for &'_ [T] { #[inline] fn run_with_ptr_slice::GlibType]) -> R>(self, f: F) -> R { if self.len() < MAX_STACK_ALLOCATION { diff --git a/glib/src/collections/slist.rs b/glib/src/collections/slist.rs index d8cf1e40fca3..fce48dd52645 100644 --- a/glib/src/collections/slist.rs +++ b/glib/src/collections/slist.rs @@ -660,7 +660,7 @@ impl<'a, T: TransparentPtrType> Iterator for Iter<'a, T> { } } -impl<'a, T: TransparentPtrType> FusedIterator for Iter<'a, T> {} +impl FusedIterator for Iter<'_, T> {} // rustdoc-stripper-ignore-next /// A non-destructive iterator over a [`SList`]. @@ -702,7 +702,7 @@ impl<'a, T: TransparentPtrType> Iterator for IterMut<'a, T> { } } -impl<'a, T: TransparentPtrType> FusedIterator for IterMut<'a, T> {} +impl FusedIterator for IterMut<'_, T> {} // rustdoc-stripper-ignore-next /// A destructive iterator over a [`SList`]. diff --git a/glib/src/collections/strv.rs b/glib/src/collections/strv.rs index 53fe12666671..05ec5821c373 100644 --- a/glib/src/collections/strv.rs +++ b/glib/src/collections/strv.rs @@ -63,8 +63,8 @@ impl std::hash::Hash for StrV { } } -impl<'a> PartialEq<[&'a str]> for StrV { - fn eq(&self, other: &[&'a str]) -> bool { +impl PartialEq<[&'_ str]> for StrV { + fn eq(&self, other: &[&'_ str]) -> bool { for (a, b) in Iterator::zip(self.iter(), other.iter()) { if a != b { return false; @@ -75,7 +75,7 @@ impl<'a> PartialEq<[&'a str]> for StrV { } } -impl<'a> PartialEq for [&'a str] { +impl PartialEq for [&'_ str] { #[inline] fn eq(&self, other: &StrV) -> bool { other.eq(self) @@ -304,9 +304,9 @@ impl From> for StrV { } } -impl<'a> From> for StrV { +impl From> for StrV { #[inline] - fn from(value: Vec<&'a str>) -> Self { + fn from(value: Vec<&'_ str>) -> Self { value.as_slice().into() } } @@ -359,9 +359,9 @@ impl From<[String; N]> for StrV { } } -impl<'a, const N: usize> From<[&'a str; N]> for StrV { +impl From<[&'_ str; N]> for StrV { #[inline] - fn from(value: [&'a str; N]) -> Self { + fn from(value: [&'_ str; N]) -> Self { unsafe { let mut s = Self::with_capacity(value.len()); for (i, item) in value.iter().enumerate() { @@ -374,9 +374,9 @@ impl<'a, const N: usize> From<[&'a str; N]> for StrV { } } -impl<'a, const N: usize> From<[&'a GStr; N]> for StrV { +impl From<[&'_ GStr; N]> for StrV { #[inline] - fn from(value: [&'a GStr; N]) -> Self { + fn from(value: [&'_ GStr; N]) -> Self { unsafe { let mut s = Self::with_capacity(value.len()); for (i, item) in value.iter().enumerate() { @@ -389,9 +389,9 @@ impl<'a, const N: usize> From<[&'a GStr; N]> for StrV { } } -impl<'a> From<&'a [&'a str]> for StrV { +impl From<&'_ [&'_ str]> for StrV { #[inline] - fn from(value: &'a [&'a str]) -> Self { + fn from(value: &'_ [&'_ str]) -> Self { unsafe { let mut s = Self::with_capacity(value.len()); for (i, item) in value.iter().enumerate() { @@ -404,9 +404,9 @@ impl<'a> From<&'a [&'a str]> for StrV { } } -impl<'a> From<&'a [&'a GStr]> for StrV { +impl From<&'_ [&'_ GStr]> for StrV { #[inline] - fn from(value: &'a [&'a GStr]) -> Self { + fn from(value: &'_ [&'_ GStr]) -> Self { unsafe { let mut s = Self::with_capacity(value.len()); for (i, item) in value.iter().enumerate() { @@ -1022,7 +1022,7 @@ impl StaticType for StrV { } } -impl<'a> StaticType for &'a [GStringPtr] { +impl StaticType for &'_ [GStringPtr] { #[inline] fn static_type() -> crate::Type { >::static_type() @@ -1097,7 +1097,7 @@ impl IntoStrV for StrV { } } -impl<'a> IntoStrV for &'a StrV { +impl IntoStrV for &'_ StrV { #[inline] fn run_with_strv R>(self, f: F) -> R { f(unsafe { std::slice::from_raw_parts(self.as_ptr(), self.len()) }) @@ -1117,21 +1117,21 @@ impl IntoStrV for Vec { } } -impl<'a> IntoStrV for Vec<&'a GString> { +impl IntoStrV for Vec<&'_ GString> { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) } } -impl<'a> IntoStrV for Vec<&'a GStr> { +impl IntoStrV for Vec<&'_ GStr> { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) } } -impl<'a> IntoStrV for Vec<&'a str> { +impl IntoStrV for Vec<&'_ str> { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) @@ -1145,7 +1145,7 @@ impl IntoStrV for Vec { } } -impl<'a> IntoStrV for Vec<&'a String> { +impl IntoStrV for Vec<&'_ String> { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) @@ -1177,7 +1177,7 @@ impl IntoStrV for &[GString] { } } -impl<'a> IntoStrV for &[&'a GString] { +impl IntoStrV for &[&GString] { #[inline] fn run_with_strv R>(self, f: F) -> R { let required_len = (self.len() + 1) * mem::size_of::<*mut c_char>(); @@ -1202,7 +1202,7 @@ impl<'a> IntoStrV for &[&'a GString] { } } -impl<'a> IntoStrV for &[&'a GStr] { +impl IntoStrV for &[&GStr] { #[inline] fn run_with_strv R>(self, f: F) -> R { let required_len = (self.len() + 1) * mem::size_of::<*mut c_char>(); @@ -1227,7 +1227,7 @@ impl<'a> IntoStrV for &[&'a GStr] { } } -impl<'a> IntoStrV for &[&'a str] { +impl IntoStrV for &[&str] { #[inline] fn run_with_strv R>(self, f: F) -> R { let required_len = (self.len() + 1) * mem::size_of::<*mut c_char>() @@ -1287,7 +1287,7 @@ impl IntoStrV for &[String] { } } -impl<'a> IntoStrV for &[&'a String] { +impl IntoStrV for &[&String] { #[inline] fn run_with_strv R>(self, f: F) -> R { let required_len = (self.len() + 1) * mem::size_of::<*mut c_char>() @@ -1324,21 +1324,21 @@ impl IntoStrV for [GString; N] { } } -impl<'a, const N: usize> IntoStrV for [&'a GString; N] { +impl IntoStrV for [&'_ GString; N] { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) } } -impl<'a, const N: usize> IntoStrV for [&'a GStr; N] { +impl IntoStrV for [&'_ GStr; N] { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) } } -impl<'a, const N: usize> IntoStrV for [&'a str; N] { +impl IntoStrV for [&'_ str; N] { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) @@ -1352,7 +1352,7 @@ impl IntoStrV for [String; N] { } } -impl<'a, const N: usize> IntoStrV for [&'a String; N] { +impl IntoStrV for [&'_ String; N] { #[inline] fn run_with_strv R>(self, f: F) -> R { self.as_slice().run_with_strv(f) diff --git a/glib/src/enums.rs b/glib/src/enums.rs index 1b812e3dc123..642f4b179b34 100644 --- a/glib/src/enums.rs +++ b/glib/src/enums.rs @@ -338,7 +338,7 @@ impl UnsafeFrom for EnumValue { } } -unsafe impl<'a, 'b> crate::value::FromValue<'a> for &'b EnumValue { +unsafe impl<'a> crate::value::FromValue<'a> for &EnumValue { type Checker = EnumTypeChecker; unsafe fn from_value(value: &'a Value) -> Self { @@ -965,7 +965,7 @@ pub type FlagsValues = EnumerationValues; /// If setting/unsetting any value fails, `build()` returns `None`. #[must_use = "The builder must be built to be used"] pub struct FlagsBuilder<'a>(&'a FlagsClass, Option); -impl<'a> FlagsBuilder<'a> { +impl FlagsBuilder<'_> { fn new(flags_class: &FlagsClass) -> FlagsBuilder { let value = unsafe { Value::from_type_unchecked(flags_class.type_()) }; FlagsBuilder(flags_class, Some(value)) @@ -1043,7 +1043,7 @@ impl<'a> FlagsBuilder<'a> { } } -unsafe impl<'a, 'b> crate::value::FromValue<'a> for Vec<&'b FlagsValue> { +unsafe impl<'a> crate::value::FromValue<'a> for Vec<&FlagsValue> { type Checker = FlagsTypeChecker; unsafe fn from_value(value: &'a Value) -> Self { diff --git a/glib/src/gstring.rs b/glib/src/gstring.rs index 93446da34ab7..7c77dd88a202 100644 --- a/glib/src/gstring.rs +++ b/glib/src/gstring.rs @@ -1996,7 +1996,7 @@ impl<'a> From<&'a GString> for Cow<'a, GStr> { } } -impl<'a> From for Cow<'a, GStr> { +impl From for Cow<'_, GStr> { #[inline] fn from(v: GString) -> Self { Cow::Owned(v) diff --git a/glib/src/main_context.rs b/glib/src/main_context.rs index 90aab2fbf4be..1213046bde55 100644 --- a/glib/src/main_context.rs +++ b/glib/src/main_context.rs @@ -176,7 +176,7 @@ impl MainContext { #[must_use = "if unused the main context will be released immediately"] pub struct MainContextAcquireGuard<'a>(&'a MainContext); -impl<'a> Drop for MainContextAcquireGuard<'a> { +impl Drop for MainContextAcquireGuard<'_> { #[doc(alias = "g_main_context_release")] #[inline] fn drop(&mut self) { @@ -188,7 +188,7 @@ impl<'a> Drop for MainContextAcquireGuard<'a> { struct ThreadDefaultContext<'a>(&'a MainContext); -impl<'a> ThreadDefaultContext<'a> { +impl ThreadDefaultContext<'_> { fn new(ctx: &MainContext) -> ThreadDefaultContext { unsafe { ffi::g_main_context_push_thread_default(ctx.to_glib_none().0); @@ -197,7 +197,7 @@ impl<'a> ThreadDefaultContext<'a> { } } -impl<'a> Drop for ThreadDefaultContext<'a> { +impl Drop for ThreadDefaultContext<'_> { #[inline] fn drop(&mut self) { unsafe { diff --git a/glib/src/match_info.rs b/glib/src/match_info.rs index 5de4baf782ac..488c7a214472 100644 --- a/glib/src/match_info.rs +++ b/glib/src/match_info.rs @@ -49,11 +49,11 @@ impl MatchInfo<'_> { } #[doc(hidden)] -impl<'input> GlibPtrDefault for MatchInfo<'input> { +impl GlibPtrDefault for MatchInfo<'_> { type GlibType = *mut ffi::GMatchInfo; } #[doc(hidden)] -unsafe impl<'input> TransparentPtrType for MatchInfo<'input> {} +unsafe impl TransparentPtrType for MatchInfo<'_> {} #[doc(hidden)] impl<'a, 'input> ToGlibPtr<'a, *mut ffi::GMatchInfo> for MatchInfo<'input> @@ -95,7 +95,7 @@ where } #[doc(hidden)] -impl<'input> FromGlibPtrNone<*mut ffi::GMatchInfo> for MatchInfo<'input> { +impl FromGlibPtrNone<*mut ffi::GMatchInfo> for MatchInfo<'_> { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GMatchInfo) -> Self { debug_assert!(!ptr.is_null()); @@ -109,14 +109,14 @@ impl<'input> FromGlibPtrNone<*mut ffi::GMatchInfo> for MatchInfo<'input> { } } #[doc(hidden)] -impl<'input> FromGlibPtrNone<*const ffi::GMatchInfo> for MatchInfo<'input> { +impl FromGlibPtrNone<*const ffi::GMatchInfo> for MatchInfo<'_> { #[inline] unsafe fn from_glib_none(ptr: *const ffi::GMatchInfo) -> Self { Self::from_glib_none(ptr.cast_mut()) } } #[doc(hidden)] -impl<'input> FromGlibPtrFull<*mut ffi::GMatchInfo> for MatchInfo<'input> { +impl FromGlibPtrFull<*mut ffi::GMatchInfo> for MatchInfo<'_> { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::GMatchInfo) -> Self { debug_assert!(!ptr.is_null()); @@ -129,7 +129,7 @@ impl<'input> FromGlibPtrFull<*mut ffi::GMatchInfo> for MatchInfo<'input> { } } #[doc(hidden)] -impl<'input> FromGlibPtrBorrow<*mut ffi::GMatchInfo> for MatchInfo<'input> { +impl FromGlibPtrBorrow<*mut ffi::GMatchInfo> for MatchInfo<'_> { #[inline] unsafe fn from_glib_borrow(ptr: *mut ffi::GMatchInfo) -> Borrowed { debug_assert!(!ptr.is_null()); @@ -142,7 +142,7 @@ impl<'input> FromGlibPtrBorrow<*mut ffi::GMatchInfo> for MatchInfo<'input> { } } #[doc(hidden)] -impl<'input> FromGlibPtrBorrow<*const ffi::GMatchInfo> for MatchInfo<'input> { +impl FromGlibPtrBorrow<*const ffi::GMatchInfo> for MatchInfo<'_> { #[inline] unsafe fn from_glib_borrow(ptr: *const ffi::GMatchInfo) -> Borrowed { from_glib_borrow::<_, Self>(ptr.cast_mut()) @@ -150,7 +150,7 @@ impl<'input> FromGlibPtrBorrow<*const ffi::GMatchInfo> for MatchInfo<'input> { } #[doc(hidden)] -impl<'input> IntoGlibPtr<*mut ffi::GMatchInfo> for MatchInfo<'input> { +impl IntoGlibPtr<*mut ffi::GMatchInfo> for MatchInfo<'_> { #[inline] unsafe fn into_glib_ptr(self) -> *mut ffi::GMatchInfo { let s = std::mem::ManuallyDrop::new(self); @@ -158,14 +158,14 @@ impl<'input> IntoGlibPtr<*mut ffi::GMatchInfo> for MatchInfo<'input> { } } #[doc(hidden)] -impl<'input> IntoGlibPtr<*const ffi::GMatchInfo> for MatchInfo<'input> { +impl IntoGlibPtr<*const ffi::GMatchInfo> for MatchInfo<'_> { #[inline] unsafe fn into_glib_ptr(self) -> *const ffi::GMatchInfo { let s = std::mem::ManuallyDrop::new(self); ToGlibPtr::<*const ffi::GMatchInfo>::to_glib_none(&*s).0 as *const _ } } -impl<'input> StaticType for MatchInfo<'input> { +impl StaticType for MatchInfo<'_> { #[inline] fn static_type() -> crate::types::Type { unsafe { from_glib(ffi::g_match_info_get_type()) } diff --git a/glib/src/object.rs b/glib/src/object.rs index 7b468deb3e4e..0b2a7a11da1e 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -3193,7 +3193,7 @@ impl Watchable for T { } #[doc(hidden)] -impl<'a, T: ObjectType> Watchable for BorrowedObject<'a, T> { +impl Watchable for BorrowedObject<'_, T> { fn watched_object(&self) -> WatchedObject { WatchedObject::new(self) } @@ -3645,7 +3645,7 @@ pub struct BindingBuilder<'a, 'f, 't> { transform_to: TransformFn<'t>, } -impl<'a, 'f, 't> fmt::Debug for BindingBuilder<'a, 'f, 't> { +impl fmt::Debug for BindingBuilder<'_, '_, '_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("BindingBuilder") .field("source", &self.source) @@ -4068,7 +4068,7 @@ impl AsMut for Class { #[derive(Debug)] pub struct ClassRef<'a, T: IsClass>(ptr::NonNull>, bool, PhantomData<&'a ()>); -impl<'a, T: IsClass> ops::Deref for ClassRef<'a, T> { +impl ops::Deref for ClassRef<'_, T> { type Target = Class; #[inline] @@ -4077,7 +4077,7 @@ impl<'a, T: IsClass> ops::Deref for ClassRef<'a, T> { } } -impl<'a, T: IsClass> Drop for ClassRef<'a, T> { +impl Drop for ClassRef<'_, T> { #[inline] fn drop(&mut self) { if self.1 { @@ -4088,8 +4088,8 @@ impl<'a, T: IsClass> Drop for ClassRef<'a, T> { } } -unsafe impl<'a, T: IsClass> Send for ClassRef<'a, T> {} -unsafe impl<'a, T: IsClass> Sync for ClassRef<'a, T> {} +unsafe impl Send for ClassRef<'_, T> {} +unsafe impl Sync for ClassRef<'_, T> {} // This should require Self: IsA, but that seems to cause a cycle error pub unsafe trait ParentClassIs: IsClass { @@ -4334,7 +4334,7 @@ impl AsMut for Interface { #[derive(Debug)] pub struct InterfaceRef<'a, T: IsInterface>(ptr::NonNull>, bool, PhantomData<&'a ()>); -impl<'a, T: IsInterface> Drop for InterfaceRef<'a, T> { +impl Drop for InterfaceRef<'_, T> { #[inline] fn drop(&mut self) { if self.1 { @@ -4345,7 +4345,7 @@ impl<'a, T: IsInterface> Drop for InterfaceRef<'a, T> { } } -impl<'a, T: IsInterface> ops::Deref for InterfaceRef<'a, T> { +impl ops::Deref for InterfaceRef<'_, T> { type Target = Interface; #[inline] @@ -4354,8 +4354,8 @@ impl<'a, T: IsInterface> ops::Deref for InterfaceRef<'a, T> { } } -unsafe impl<'a, T: IsInterface> Send for InterfaceRef<'a, T> {} -unsafe impl<'a, T: IsInterface> Sync for InterfaceRef<'a, T> {} +unsafe impl Send for InterfaceRef<'_, T> {} +unsafe impl Sync for InterfaceRef<'_, T> {} // rustdoc-stripper-ignore-next /// Trait implemented by interface types. @@ -4430,8 +4430,8 @@ pub struct BorrowedObject<'a, T> { phantom: PhantomData<&'a T>, } -unsafe impl<'a, T: Send + Sync> Send for BorrowedObject<'a, T> {} -unsafe impl<'a, T: Send + Sync> Sync for BorrowedObject<'a, T> {} +unsafe impl Send for BorrowedObject<'_, T> {} +unsafe impl Sync for BorrowedObject<'_, T> {} impl<'a, T: ObjectType> BorrowedObject<'a, T> { // rustdoc-stripper-ignore-next @@ -4459,7 +4459,7 @@ impl<'a, T: ObjectType> BorrowedObject<'a, T> { } } -impl<'a, T> ops::Deref for BorrowedObject<'a, T> { +impl ops::Deref for BorrowedObject<'_, T> { type Target = T; #[inline] @@ -4468,30 +4468,28 @@ impl<'a, T> ops::Deref for BorrowedObject<'a, T> { } } -impl<'a, T> AsRef for BorrowedObject<'a, T> { +impl AsRef for BorrowedObject<'_, T> { #[inline] fn as_ref(&self) -> &T { unsafe { &*(&self.ptr as *const _ as *const T) } } } -impl<'a, T: PartialEq> PartialEq for BorrowedObject<'a, T> { +impl PartialEq for BorrowedObject<'_, T> { #[inline] fn eq(&self, other: &T) -> bool { ::eq(self, other) } } -impl<'a, T: PartialOrd> PartialOrd for BorrowedObject<'a, T> { +impl PartialOrd for BorrowedObject<'_, T> { #[inline] fn partial_cmp(&self, other: &T) -> Option { ::partial_cmp(self, other) } } -impl<'a, T: crate::clone::Downgrade + ObjectType> crate::clone::Downgrade - for BorrowedObject<'a, T> -{ +impl crate::clone::Downgrade for BorrowedObject<'_, T> { type Weak = ::Weak; #[inline] diff --git a/glib/src/translate.rs b/glib/src/translate.rs index 0744f4285acc..390242f2cc68 100644 --- a/glib/src/translate.rs +++ b/glib/src/translate.rs @@ -425,7 +425,7 @@ pub trait GlibPtrDefault { type GlibType: Ptr; } -impl<'a, T: ?Sized + GlibPtrDefault> GlibPtrDefault for &'a T { +impl GlibPtrDefault for &T { type GlibType = ::GlibType; } @@ -468,7 +468,7 @@ pub trait ToGlibPtrMut<'a, P: Copy> { /// /// The pointer in the `Stash` is only valid for the lifetime of the `Stash`. #[allow(clippy::wrong_self_convention)] - fn to_glib_none_mut(&'a mut self) -> StashMut; + fn to_glib_none_mut(&'a mut self) -> StashMut<'a, P, Self>; } impl<'a, P: Ptr, T: ToGlibPtr<'a, P>> ToGlibPtr<'a, P> for Option { diff --git a/glib/src/types.rs b/glib/src/types.rs index bf300164ac81..15c38be9c5f4 100644 --- a/glib/src/types.rs +++ b/glib/src/types.rs @@ -355,14 +355,14 @@ impl From for crate::Value { } } -impl<'a, T: ?Sized + StaticType> StaticType for &'a T { +impl StaticType for &'_ T { #[inline] fn static_type() -> Type { T::static_type() } } -impl<'a, T: ?Sized + StaticType> StaticType for &'a mut T { +impl StaticType for &'_ mut T { #[inline] fn static_type() -> Type { T::static_type() @@ -555,7 +555,7 @@ builtin!(PathBuf, STRING); builtin!(Path, STRING); builtin!(Pointer, POINTER); -impl<'a> StaticType for [&'a str] { +impl StaticType for [&'_ str] { #[inline] fn static_type() -> Type { unsafe { from_glib(ffi::g_strv_get_type()) } diff --git a/glib/src/value.rs b/glib/src/value.rs index 157083d87e1e..42cdd7b267a6 100644 --- a/glib/src/value.rs +++ b/glib/src/value.rs @@ -571,7 +571,9 @@ impl Value { /// /// Returns `Ok` if the type is correct. #[inline] - pub fn get<'a, T>(&'a self) -> Result::Checker as ValueTypeChecker>::Error> + pub fn get<'a, T>( + &'a self, + ) -> Result>::Checker as ValueTypeChecker>::Error> where T: FromValue<'a>, { @@ -727,7 +729,7 @@ impl ToValue for Value { } } -impl<'a> ToValue for &'a Value { +impl ToValue for &Value { #[inline] fn to_value(&self) -> Value { (*self).clone() @@ -780,7 +782,7 @@ impl ToValue for SendValue { } } -impl<'a> ToValue for &'a SendValue { +impl ToValue for &SendValue { #[inline] fn to_value(&self) -> Value { unsafe { from_glib_none(self.to_glib_none().0) } @@ -1034,7 +1036,7 @@ impl From> for Value { } } -impl<'a> ToValue for [&'a str] { +impl ToValue for [&'_ str] { fn to_value(&self) -> Value { unsafe { let mut value = Value::for_value_type::>(); @@ -1049,7 +1051,7 @@ impl<'a> ToValue for [&'a str] { } } -impl<'a> ToValue for &'a [&'a str] { +impl ToValue for &'_ [&'_ str] { fn to_value(&self) -> Value { unsafe { let mut value = Value::for_value_type::>(); diff --git a/glib/src/variant.rs b/glib/src/variant.rs index d1df3bae1617..df8f0e1ca7a6 100644 --- a/glib/src/variant.rs +++ b/glib/src/variant.rs @@ -998,7 +998,7 @@ impl StaticVariantType for Variant { } } -impl<'a, T: ?Sized + ToVariant> ToVariant for &'a T { +impl ToVariant for &T { fn to_variant(&self) -> Variant { ::to_variant(self) } @@ -1011,7 +1011,7 @@ impl<'a, T: Into + Clone> From<&'a T> for Variant { } } -impl<'a, T: ?Sized + StaticVariantType> StaticVariantType for &'a T { +impl StaticVariantType for &T { fn static_variant_type() -> Cow<'static, VariantTy> { ::static_variant_type() } diff --git a/glib/src/variant_iter.rs b/glib/src/variant_iter.rs index a0835dc88a06..f98616d54dc2 100644 --- a/glib/src/variant_iter.rs +++ b/glib/src/variant_iter.rs @@ -196,9 +196,9 @@ impl<'a> DoubleEndedIterator for VariantStrIter<'a> { } } -impl<'a> ExactSizeIterator for VariantStrIter<'a> {} +impl ExactSizeIterator for VariantStrIter<'_> {} -impl<'a> FusedIterator for VariantStrIter<'a> {} +impl FusedIterator for VariantStrIter<'_> {} #[cfg(test)] mod tests { diff --git a/glib/src/variant_type.rs b/glib/src/variant_type.rs index 8e846ad67e0d..ee477896bc22 100644 --- a/glib/src/variant_type.rs +++ b/glib/src/variant_type.rs @@ -967,7 +967,7 @@ impl<'a> Iterator for VariantTyIterator<'a> { } } -impl<'a> iter::FusedIterator for VariantTyIterator<'a> {} +impl iter::FusedIterator for VariantTyIterator<'_> {} #[cfg(test)] mod tests { diff --git a/glib/src/wrapper.rs b/glib/src/wrapper.rs index a45b41fa123e..68cf66b691a9 100644 --- a/glib/src/wrapper.rs +++ b/glib/src/wrapper.rs @@ -272,7 +272,6 @@ /// [#shared]: #shared /// [#object]: #object /// [#non-derivable-classes]: #non-derivable-classes - #[macro_export] macro_rules! wrapper { // Boxed diff --git a/pango/src/attr_iterator.rs b/pango/src/attr_iterator.rs index bd8834335c3c..90c75272fc8e 100644 --- a/pango/src/attr_iterator.rs +++ b/pango/src/attr_iterator.rs @@ -12,7 +12,7 @@ pub struct AttrIterator<'list> { list: PhantomData<&'list crate::AttrList>, } -impl<'list> Clone for AttrIterator<'list> { +impl Clone for AttrIterator<'_> { #[inline] fn clone(&self) -> Self { let ptr = unsafe { @@ -25,7 +25,7 @@ impl<'list> Clone for AttrIterator<'list> { } } -impl<'list> Drop for AttrIterator<'list> { +impl Drop for AttrIterator<'_> { #[inline] fn drop(&mut self) { unsafe { @@ -36,14 +36,14 @@ impl<'list> Drop for AttrIterator<'list> { #[cfg(feature = "v1_44")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))] -impl<'list> glib::prelude::StaticType for AttrIterator<'list> { +impl glib::prelude::StaticType for AttrIterator<'_> { #[inline] fn static_type() -> glib::Type { unsafe { from_glib(ffi::pango_attr_iterator_get_type()) } } } -impl<'list> AttrIterator<'list> { +impl AttrIterator<'_> { #[doc(alias = "pango_attr_iterator_get")] pub fn get(&self, type_: AttrType) -> Option { unsafe { @@ -121,7 +121,7 @@ impl<'list> IntoIterator for AttrIterator<'list> { #[repr(transparent)] pub struct AttrIntoIter<'list>(Option>); -impl<'list> Iterator for AttrIntoIter<'list> { +impl Iterator for AttrIntoIter<'_> { type Item = SList; #[inline] fn next(&mut self) -> Option { @@ -137,7 +137,7 @@ impl<'list> Iterator for AttrIntoIter<'list> { } } -impl<'list> std::iter::FusedIterator for AttrIntoIter<'list> {} +impl std::iter::FusedIterator for AttrIntoIter<'_> {} #[doc(hidden)] impl<'a, 'list> ToGlibPtr<'a, *const ffi::PangoAttrIterator> for AttrIterator<'list> @@ -164,7 +164,7 @@ where } #[doc(hidden)] -impl<'list> FromGlibPtrFull<*mut ffi::PangoAttrIterator> for AttrIterator<'list> { +impl FromGlibPtrFull<*mut ffi::PangoAttrIterator> for AttrIterator<'_> { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::PangoAttrIterator) -> Self { Self { diff --git a/pango/src/glyph_item_iter.rs b/pango/src/glyph_item_iter.rs index 9fbe0bb8ce21..4bf275daf5f3 100644 --- a/pango/src/glyph_item_iter.rs +++ b/pango/src/glyph_item_iter.rs @@ -13,7 +13,7 @@ pub struct GlyphItemIter<'item> { item: PhantomData<&'item GlyphItem>, } -impl<'item> StaticType for GlyphItemIter<'item> { +impl StaticType for GlyphItemIter<'_> { #[inline] fn static_type() -> glib::Type { unsafe { from_glib(ffi::pango_glyph_item_iter_get_type()) } @@ -132,7 +132,7 @@ impl<'item> IntoIterator for GlyphItemIter<'item> { #[repr(transparent)] pub struct GlyphItemIntoIter<'item>(Option>); -impl<'item> Iterator for GlyphItemIntoIter<'item> { +impl Iterator for GlyphItemIntoIter<'_> { type Item = (i32, i32, i32, i32, i32, i32); fn next(&mut self) -> Option { if let Some(iter) = &mut self.0 { @@ -154,7 +154,7 @@ impl<'item> Iterator for GlyphItemIntoIter<'item> { } } -impl<'item> std::iter::FusedIterator for GlyphItemIntoIter<'item> {} +impl std::iter::FusedIterator for GlyphItemIntoIter<'_> {} #[doc(hidden)] impl<'a, 'item> ToGlibPtr<'a, *const ffi::PangoGlyphItemIter> for GlyphItemIter<'item> diff --git a/pango/src/script_iter.rs b/pango/src/script_iter.rs index d5d7a2e2f203..dcf5c28df359 100644 --- a/pango/src/script_iter.rs +++ b/pango/src/script_iter.rs @@ -14,7 +14,7 @@ pub struct ScriptIter<'text> { #[cfg(feature = "v1_44")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))] -impl<'text> Clone for ScriptIter<'text> { +impl Clone for ScriptIter<'_> { #[inline] fn clone(&self) -> Self { let ptr = unsafe { @@ -30,7 +30,7 @@ impl<'text> Clone for ScriptIter<'text> { } } -impl<'text> Drop for ScriptIter<'text> { +impl Drop for ScriptIter<'_> { #[inline] fn drop(&mut self) { unsafe { @@ -41,7 +41,7 @@ impl<'text> Drop for ScriptIter<'text> { #[cfg(feature = "v1_44")] #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))] -impl<'text> glib::prelude::StaticType for ScriptIter<'text> { +impl glib::prelude::StaticType for ScriptIter<'_> { #[inline] fn static_type() -> glib::Type { unsafe { from_glib(ffi::pango_script_iter_get_type()) } @@ -114,7 +114,7 @@ impl<'text> Iterator for ScriptIntoIter<'text> { } } -impl<'text> std::iter::FusedIterator for ScriptIntoIter<'text> {} +impl std::iter::FusedIterator for ScriptIntoIter<'_> {} #[doc(hidden)] impl<'a, 'text> ToGlibPtr<'a, *const ffi::PangoScriptIter> for ScriptIter<'text> @@ -141,7 +141,7 @@ where } #[doc(hidden)] -impl<'text> FromGlibPtrFull<*mut ffi::PangoScriptIter> for ScriptIter<'text> { +impl FromGlibPtrFull<*mut ffi::PangoScriptIter> for ScriptIter<'_> { #[inline] unsafe fn from_glib_full(ptr: *mut ffi::PangoScriptIter) -> Self { Self { From a9f9468e9368a30859ca94ed8f320b78389ed442 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 31 Oct 2024 14:36:10 +0100 Subject: [PATCH 23/23] Ignore manual_c_str_literals clippy warning --- gdk-pixbuf/src/lib.rs | 1 + gio/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/gdk-pixbuf/src/lib.rs b/gdk-pixbuf/src/lib.rs index 1d662e697f2c..99e3f44bacce 100644 --- a/gdk-pixbuf/src/lib.rs +++ b/gdk-pixbuf/src/lib.rs @@ -9,6 +9,7 @@ pub use gio; pub use glib; #[allow(clippy::too_many_arguments)] +#[allow(clippy::manual_c_str_literals)] mod auto; pub mod subclass; diff --git a/gio/src/lib.rs b/gio/src/lib.rs index c15f62b8cf1f..02b25cdca0e2 100644 --- a/gio/src/lib.rs +++ b/gio/src/lib.rs @@ -4,6 +4,7 @@ #![allow(clippy::type_complexity)] #![allow(clippy::too_many_arguments)] #![allow(clippy::missing_safety_doc)] +#![allow(clippy::manual_c_str_literals)] #![doc = include_str!("../README.md")] pub use gio_sys as ffi;