@@ -9,160 +9,38 @@ use crate::{prelude::*, AsyncInitable, Cancellable};
9
9
10
10
impl AsyncInitable {
11
11
// rustdoc-stripper-ignore-next
12
- /// Create a new instance of an async initable object with the given properties .
12
+ /// Create a new instance of an async initable object with the default property values .
13
13
///
14
14
/// Similar to [`Object::new`] but can fail because the object initialization in
15
15
/// `AsyncInitable::init` failed.
16
- #[ allow( clippy:: new_ret_no_self) ]
17
16
#[ doc( alias = "g_async_initable_new_async" ) ]
18
17
#[ track_caller]
19
- #[ deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default() instead" ]
20
- #[ allow( deprecated) ]
18
+ #[ allow( clippy:: new_ret_no_self) ]
21
19
pub fn new <
22
20
O : IsClass + IsA < Object > + IsA < AsyncInitable > ,
23
21
Q : FnOnce ( Result < O , glib:: Error > ) + ' static ,
24
22
> (
25
- properties : & [ ( & str , & dyn ToValue ) ] ,
26
23
io_priority : glib:: Priority ,
27
24
cancellable : Option < & impl IsA < Cancellable > > ,
28
25
callback : Q ,
29
26
) {
30
- Self :: with_type (
31
- O :: static_type ( ) ,
32
- properties,
33
- io_priority,
34
- cancellable,
35
- move |res| callback ( res. map ( |o| unsafe { o. unsafe_cast ( ) } ) ) ,
36
- )
37
- }
38
-
39
- // rustdoc-stripper-ignore-next
40
- /// Create a new instance of an async initable object with the given properties as future.
41
- ///
42
- /// Similar to [`Object::new`] but can fail because the object initialization in
43
- /// `AsyncInitable::init` failed.
44
- #[ doc( alias = "g_async_initable_new_async" ) ]
45
- #[ track_caller]
46
- #[ deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_future() instead" ]
47
- #[ allow( deprecated) ]
48
- pub fn new_future < O : IsClass + IsA < Object > + IsA < AsyncInitable > > (
49
- properties : & [ ( & str , & dyn ToValue ) ] ,
50
- io_priority : glib:: Priority ,
51
- ) -> Pin < Box_ < dyn std:: future:: Future < Output = Result < O , glib:: Error > > + ' static > > {
52
- Box :: pin (
53
- Self :: with_type_future ( O :: static_type ( ) , properties, io_priority)
54
- . map_ok ( |o| unsafe { o. unsafe_cast ( ) } ) ,
55
- )
56
- }
57
-
58
- // rustdoc-stripper-ignore-next
59
- /// Create a new instance of an async initable object of the given type with the given properties.
60
- ///
61
- /// Similar to [`Object::with_type`] but can fail because the object initialization in
62
- /// `AsyncInitable::init` failed.
63
- #[ doc( alias = "g_async_initable_new_async" ) ]
64
- #[ track_caller]
65
- #[ deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_with_type() instead" ]
66
- pub fn with_type < Q : FnOnce ( Result < Object , glib:: Error > ) + ' static > (
67
- type_ : Type ,
68
- properties : & [ ( & str , & dyn ToValue ) ] ,
69
- io_priority : glib:: Priority ,
70
- cancellable : Option < & impl IsA < Cancellable > > ,
71
- callback : Q ,
72
- ) {
73
- if !type_. is_a ( AsyncInitable :: static_type ( ) ) {
74
- panic ! ( "Type '{type_}' is not async initable" ) ;
75
- }
76
-
77
- let mut property_values = smallvec:: SmallVec :: < [ _ ; 16 ] > :: with_capacity ( properties. len ( ) ) ;
78
- for ( name, value) in properties {
79
- property_values. push ( ( * name, value. to_value ( ) ) ) ;
80
- }
81
-
82
- unsafe {
83
- let obj = Object :: new_internal ( type_, & mut property_values) ;
84
- obj. unsafe_cast_ref :: < Self > ( ) . init_async (
85
- io_priority,
86
- cancellable,
87
- glib:: clone!( @strong obj => move |res| {
88
- callback( res. map( |_| obj) ) ;
89
- } ) ,
90
- )
91
- } ;
92
- }
93
-
94
- // rustdoc-stripper-ignore-next
95
- /// Create a new instance of an async initable object of the given type with the given properties as future.
96
- ///
97
- /// Similar to [`Object::with_type`] but can fail because the object initialization in
98
- /// `AsyncInitable::init` failed.
99
- #[ doc( alias = "g_async_initable_new_async" ) ]
100
- #[ track_caller]
101
- #[ deprecated = "Use AsyncInitable::builder() or AsyncInitable::new_default_future() instead" ]
102
- pub fn with_type_future (
103
- type_ : Type ,
104
- properties : & [ ( & str , & dyn ToValue ) ] ,
105
- io_priority : glib:: Priority ,
106
- ) -> Pin < Box_ < dyn std:: future:: Future < Output = Result < Object , glib:: Error > > + ' static > > {
107
- if !type_. is_a ( AsyncInitable :: static_type ( ) ) {
108
- panic ! ( "Type '{type_}' is not async initable" ) ;
109
- }
110
-
111
- let mut property_values = smallvec:: SmallVec :: < [ _ ; 16 ] > :: with_capacity ( properties. len ( ) ) ;
112
- for ( name, value) in properties {
113
- property_values. push ( ( * name, value. to_value ( ) ) ) ;
114
- }
115
-
116
- unsafe {
117
- // FIXME: object construction should ideally happen as part of the future
118
- let obj = Object :: new_internal ( type_, & mut property_values) ;
119
- Box_ :: pin ( crate :: GioFuture :: new (
120
- & obj,
121
- move |obj, cancellable, send| {
122
- obj. unsafe_cast_ref :: < Self > ( ) . init_async (
123
- io_priority,
124
- Some ( cancellable) ,
125
- glib:: clone!( @strong obj => move |res| {
126
- send. resolve( res. map( |_| obj) ) ;
127
- } ) ,
128
- ) ;
129
- } ,
130
- ) )
131
- }
132
- }
133
-
134
- // rustdoc-stripper-ignore-next
135
- /// Create a new instance of an async initable object with the default property values.
136
- ///
137
- /// Similar to [`Object::new_default`] but can fail because the object initialization in
138
- /// `AsyncInitable::init` failed.
139
- #[ doc( alias = "g_async_initable_new_async" ) ]
140
- #[ track_caller]
141
- pub fn new_default <
142
- O : IsClass + IsA < Object > + IsA < AsyncInitable > ,
143
- Q : FnOnce ( Result < O , glib:: Error > ) + ' static ,
144
- > (
145
- io_priority : glib:: Priority ,
146
- cancellable : Option < & impl IsA < Cancellable > > ,
147
- callback : Q ,
148
- ) {
149
- Self :: new_default_with_type ( O :: static_type ( ) , io_priority, cancellable, move |res| {
27
+ Self :: with_type ( O :: static_type ( ) , io_priority, cancellable, move |res| {
150
28
callback ( res. map ( |o| unsafe { o. unsafe_cast ( ) } ) )
151
29
} )
152
30
}
153
31
154
32
// rustdoc-stripper-ignore-next
155
33
/// Create a new instance of an async initable object with the default property values as future.
156
34
///
157
- /// Similar to [`Object::new_default `] but can fail because the object initialization in
35
+ /// Similar to [`Object::new `] but can fail because the object initialization in
158
36
/// `AsyncInitable::init` failed.
159
37
#[ doc( alias = "g_async_initable_new_async" ) ]
160
38
#[ track_caller]
161
- pub fn new_default_future < O : IsClass + IsA < Object > + IsA < AsyncInitable > > (
39
+ pub fn new_future < O : IsClass + IsA < Object > + IsA < AsyncInitable > > (
162
40
io_priority : glib:: Priority ,
163
41
) -> Pin < Box_ < dyn std:: future:: Future < Output = Result < O , glib:: Error > > + ' static > > {
164
42
Box :: pin (
165
- Self :: new_default_with_type_future ( O :: static_type ( ) , io_priority)
43
+ Self :: with_type_future ( O :: static_type ( ) , io_priority)
166
44
. map_ok ( |o| unsafe { o. unsafe_cast ( ) } ) ,
167
45
)
168
46
}
@@ -171,11 +49,11 @@ impl AsyncInitable {
171
49
/// Create a new instance of an async initable object of the given type with the default
172
50
/// property values.
173
51
///
174
- /// Similar to [`Object::new_default_with_type `] but can fail because the object initialization in
52
+ /// Similar to [`Object::with_type `] but can fail because the object initialization in
175
53
/// `AsyncInitable::init` failed.
176
54
#[ doc( alias = "g_async_initable_new_async" ) ]
177
55
#[ track_caller]
178
- pub fn new_default_with_type < Q : FnOnce ( Result < Object , glib:: Error > ) + ' static > (
56
+ pub fn with_type < Q : FnOnce ( Result < Object , glib:: Error > ) + ' static > (
179
57
type_ : Type ,
180
58
io_priority : glib:: Priority ,
181
59
cancellable : Option < & impl IsA < Cancellable > > ,
@@ -200,11 +78,11 @@ impl AsyncInitable {
200
78
// rustdoc-stripper-ignore-next
201
79
/// Create a new instance of an async initable object of the given type with the default property values as future.
202
80
///
203
- /// Similar to [`Object::new_default_with_type `] but can fail because the object initialization in
81
+ /// Similar to [`Object::with_type `] but can fail because the object initialization in
204
82
/// `AsyncInitable::init` failed.
205
83
#[ doc( alias = "g_async_initable_new_async" ) ]
206
84
#[ track_caller]
207
- pub fn new_default_with_type_future (
85
+ pub fn with_type_future (
208
86
type_ : Type ,
209
87
io_priority : glib:: Priority ,
210
88
) -> Pin < Box_ < dyn std:: future:: Future < Output = Result < Object , glib:: Error > > + ' static > > {
@@ -229,82 +107,6 @@ impl AsyncInitable {
229
107
}
230
108
}
231
109
232
- // rustdoc-stripper-ignore-next
233
- /// Create a new instance of an async initable object of the given type with the given properties.
234
- ///
235
- /// Similar to [`Object::with_values`] but can fail because the object initialization in
236
- /// `AsyncInitable::init` failed.
237
- #[ doc( alias = "g_async_initable_new_async" ) ]
238
- #[ track_caller]
239
- #[ deprecated = "Use AsyncInitable::with_mut_values() instead" ]
240
- pub fn with_values < Q : FnOnce ( Result < Object , glib:: Error > ) + ' static > (
241
- type_ : Type ,
242
- properties : & [ ( & str , glib:: Value ) ] ,
243
- io_priority : glib:: Priority ,
244
- cancellable : Option < & impl IsA < Cancellable > > ,
245
- callback : Q ,
246
- ) {
247
- if !type_. is_a ( AsyncInitable :: static_type ( ) ) {
248
- panic ! ( "Type '{type_}' is not async initable" ) ;
249
- }
250
-
251
- let mut property_values = smallvec:: SmallVec :: < [ _ ; 16 ] > :: with_capacity ( properties. len ( ) ) ;
252
- for ( name, value) in properties {
253
- property_values. push ( ( * name, value. clone ( ) ) ) ;
254
- }
255
-
256
- unsafe {
257
- let obj = Object :: new_internal ( type_, & mut property_values) ;
258
- obj. unsafe_cast_ref :: < Self > ( ) . init_async (
259
- io_priority,
260
- cancellable,
261
- glib:: clone!( @strong obj => move |res| {
262
- callback( res. map( |_| obj) ) ;
263
- } ) ,
264
- )
265
- } ;
266
- }
267
-
268
- // rustdoc-stripper-ignore-next
269
- /// Create a new instance of an async initable object of the given type with the given properties as a future.
270
- ///
271
- /// Similar to [`Object::with_values`] but can fail because the object initialization in
272
- /// `AsyncInitable::init` failed.
273
- #[ doc( alias = "g_async_initable_new_async" ) ]
274
- #[ track_caller]
275
- #[ deprecated = "Use AsyncInitable::with_mut_values_future() instead" ]
276
- pub fn with_values_future (
277
- type_ : Type ,
278
- properties : & [ ( & str , glib:: Value ) ] ,
279
- io_priority : glib:: Priority ,
280
- ) -> Pin < Box_ < dyn std:: future:: Future < Output = Result < Object , glib:: Error > > + ' static > > {
281
- if !type_. is_a ( AsyncInitable :: static_type ( ) ) {
282
- panic ! ( "Type '{type_}' is not async initable" ) ;
283
- }
284
-
285
- let mut property_values = smallvec:: SmallVec :: < [ _ ; 16 ] > :: with_capacity ( properties. len ( ) ) ;
286
- for ( name, value) in properties {
287
- property_values. push ( ( * name, value. clone ( ) ) ) ;
288
- }
289
-
290
- unsafe {
291
- // FIXME: object construction should ideally happen as part of the future
292
- let obj = Object :: new_internal ( type_, & mut property_values) ;
293
- Box_ :: pin ( crate :: GioFuture :: new (
294
- & obj,
295
- move |obj, cancellable, send| {
296
- obj. unsafe_cast_ref :: < Self > ( ) . init_async (
297
- io_priority,
298
- Some ( cancellable) ,
299
- glib:: clone!( @strong obj => move |res| {
300
- send. resolve( res. map( |_| obj) ) ;
301
- } ) ,
302
- ) ;
303
- } ,
304
- ) )
305
- }
306
- }
307
-
308
110
// rustdoc-stripper-ignore-next
309
111
/// Create a new instance of an async initable object of the given type with the given properties as mutable values.
310
112
///
0 commit comments