@@ -11,7 +11,7 @@ use glib::{prelude::*, translate::*};
11
11
pub trait DBusMethodCall : Sized {
12
12
fn parse_call (
13
13
obj_path : & str ,
14
- interface : & str ,
14
+ interface : Option < & str > ,
15
15
method : & str ,
16
16
params : glib:: Variant ,
17
17
) -> Result < Self , glib:: Error > ;
@@ -46,7 +46,7 @@ impl<'a, T: DBusMethodCall> MethodCallBuilder<'a, T> {
46
46
/// safer interface where the callback returns a result directly.
47
47
pub fn invoke < F > ( self , f : F ) -> RegistrationBuilder < ' a >
48
48
where
49
- F : Fn ( DBusConnection , & str , T , DBusMethodInvocation ) + ' static ,
49
+ F : Fn ( DBusConnection , Option < & str > , T , DBusMethodInvocation ) + ' static ,
50
50
{
51
51
self . registration . method_call (
52
52
move |connection, sender, obj_path, interface, method, params, invocation| {
@@ -74,7 +74,8 @@ impl<'a, T: DBusMethodCall> MethodCallBuilder<'a, T> {
74
74
/// See [`DBusMethodInvocation::return_result`] for details.
75
75
pub fn invoke_and_return < F > ( self , f : F ) -> RegistrationBuilder < ' a >
76
76
where
77
- F : Fn ( DBusConnection , & str , T ) -> Result < Option < glib:: Variant > , glib:: Error > + ' static ,
77
+ F : Fn ( DBusConnection , Option < & str > , T ) -> Result < Option < glib:: Variant > , glib:: Error >
78
+ + ' static ,
78
79
{
79
80
self . invoke ( move |connection, sender, call, invocation| {
80
81
invocation. return_result ( f ( connection, sender, call) )
@@ -97,7 +98,7 @@ impl<'a, T: DBusMethodCall> MethodCallBuilder<'a, T> {
97
98
/// See [`DBusMethodInvocation::return_future_local`] for details.
98
99
pub fn invoke_and_return_future_local < F , Fut > ( self , f : F ) -> RegistrationBuilder < ' a >
99
100
where
100
- F : Fn ( DBusConnection , & str , T ) -> Fut + ' static ,
101
+ F : Fn ( DBusConnection , Option < & str > , T ) -> Fut + ' static ,
101
102
Fut : Future < Output = Result < Option < glib:: Variant > , glib:: Error > > + ' static ,
102
103
{
103
104
self . invoke ( move |connection, sender, call, invocation| {
@@ -128,18 +129,37 @@ pub struct RegistrationBuilder<'a> {
128
129
interface_info : & ' a DBusInterfaceInfo ,
129
130
#[ allow( clippy:: type_complexity) ]
130
131
method_call : Option <
131
- Box_ < dyn Fn ( DBusConnection , & str , & str , & str , & str , glib:: Variant , DBusMethodInvocation ) > ,
132
+ Box_ <
133
+ dyn Fn (
134
+ DBusConnection ,
135
+ Option < & str > ,
136
+ & str ,
137
+ Option < & str > ,
138
+ & str ,
139
+ glib:: Variant ,
140
+ DBusMethodInvocation ,
141
+ ) ,
142
+ > ,
132
143
> ,
133
144
#[ allow( clippy:: type_complexity) ]
134
- get_property : Option < Box_ < dyn Fn ( DBusConnection , & str , & str , & str , & str ) -> glib:: Variant > > ,
145
+ get_property :
146
+ Option < Box_ < dyn Fn ( DBusConnection , Option < & str > , & str , & str , & str ) -> glib:: Variant > > ,
135
147
#[ allow( clippy:: type_complexity) ]
136
148
set_property :
137
- Option < Box_ < dyn Fn ( DBusConnection , & str , & str , & str , & str , glib:: Variant ) -> bool > > ,
149
+ Option < Box_ < dyn Fn ( DBusConnection , Option < & str > , & str , & str , & str , glib:: Variant ) -> bool > > ,
138
150
}
139
151
140
152
impl < ' a > RegistrationBuilder < ' a > {
141
153
pub fn method_call <
142
- F : Fn ( DBusConnection , & str , & str , & str , & str , glib:: Variant , DBusMethodInvocation ) + ' static ,
154
+ F : Fn (
155
+ DBusConnection ,
156
+ Option < & str > ,
157
+ & str ,
158
+ Option < & str > ,
159
+ & str ,
160
+ glib:: Variant ,
161
+ DBusMethodInvocation ,
162
+ ) + ' static ,
143
163
> (
144
164
mut self ,
145
165
f : F ,
@@ -162,7 +182,9 @@ impl<'a> RegistrationBuilder<'a> {
162
182
}
163
183
164
184
#[ doc( alias = "get_property" ) ]
165
- pub fn property < F : Fn ( DBusConnection , & str , & str , & str , & str ) -> glib:: Variant + ' static > (
185
+ pub fn property <
186
+ F : Fn ( DBusConnection , Option < & str > , & str , & str , & str ) -> glib:: Variant + ' static ,
187
+ > (
166
188
mut self ,
167
189
f : F ,
168
190
) -> Self {
@@ -171,7 +193,7 @@ impl<'a> RegistrationBuilder<'a> {
171
193
}
172
194
173
195
pub fn set_property <
174
- F : Fn ( DBusConnection , & str , & str , & str , & str , glib:: Variant ) -> bool + ' static ,
196
+ F : Fn ( DBusConnection , Option < & str > , & str , & str , & str , glib:: Variant ) -> bool + ' static ,
175
197
> (
176
198
mut self ,
177
199
f : F ,
@@ -191,9 +213,9 @@ impl<'a> RegistrationBuilder<'a> {
191
213
. map ( |f| {
192
214
glib:: Closure :: new_local ( move |args| {
193
215
let conn = args[ 0 ] . get :: < DBusConnection > ( ) . unwrap ( ) ;
194
- let sender = args[ 1 ] . get :: < & str > ( ) . unwrap ( ) ;
216
+ let sender = args[ 1 ] . get :: < Option < & str > > ( ) . unwrap ( ) ;
195
217
let object_path = args[ 2 ] . get :: < & str > ( ) . unwrap ( ) ;
196
- let interface_name = args[ 3 ] . get :: < & str > ( ) . unwrap ( ) ;
218
+ let interface_name = args[ 3 ] . get :: < Option < & str > > ( ) . unwrap ( ) ;
197
219
let method_name = args[ 4 ] . get :: < & str > ( ) . unwrap ( ) ;
198
220
let parameters = args[ 5 ] . get :: < glib:: Variant > ( ) . unwrap ( ) ;
199
221
let invocation = args[ 6 ] . get :: < DBusMethodInvocation > ( ) . unwrap ( ) ;
@@ -215,7 +237,7 @@ impl<'a> RegistrationBuilder<'a> {
215
237
. map ( |f| {
216
238
glib:: Closure :: new_local ( move |args| {
217
239
let conn = args[ 0 ] . get :: < DBusConnection > ( ) . unwrap ( ) ;
218
- let sender = args[ 1 ] . get :: < & str > ( ) . unwrap ( ) ;
240
+ let sender = args[ 1 ] . get :: < Option < & str > > ( ) . unwrap ( ) ;
219
241
let object_path = args[ 2 ] . get :: < & str > ( ) . unwrap ( ) ;
220
242
let interface_name = args[ 3 ] . get :: < & str > ( ) . unwrap ( ) ;
221
243
let property_name = args[ 4 ] . get :: < & str > ( ) . unwrap ( ) ;
@@ -237,7 +259,7 @@ impl<'a> RegistrationBuilder<'a> {
237
259
. map ( |f| {
238
260
glib:: Closure :: new_local ( move |args| {
239
261
let conn = args[ 0 ] . get :: < DBusConnection > ( ) . unwrap ( ) ;
240
- let sender = args[ 1 ] . get :: < & str > ( ) . unwrap ( ) ;
262
+ let sender = args[ 1 ] . get :: < Option < & str > > ( ) . unwrap ( ) ;
241
263
let object_path = args[ 2 ] . get :: < & str > ( ) . unwrap ( ) ;
242
264
let interface_name = args[ 3 ] . get :: < & str > ( ) . unwrap ( ) ;
243
265
let property_name = args[ 4 ] . get :: < & str > ( ) . unwrap ( ) ;
0 commit comments