@@ -165,11 +165,12 @@ pub fn get_current_locals(py: Python) -> PyResult<TaskLocals> {
165
165
/// # Ok(())
166
166
/// # }).unwrap();
167
167
/// ```
168
- pub fn run_until_complete < F > ( event_loop : & PyAny , fut : F ) -> PyResult < ( ) >
168
+ pub fn run_until_complete < F , T > ( event_loop : & PyAny , fut : F ) -> PyResult < T >
169
169
where
170
- F : Future < Output = PyResult < ( ) > > + Send + ' static ,
170
+ F : Future < Output = PyResult < T > > + Send + ' static ,
171
+ T : Send + Sync + ' static ,
171
172
{
172
- generic:: run_until_complete :: < AsyncStdRuntime , _ > ( event_loop, fut)
173
+ generic:: run_until_complete :: < AsyncStdRuntime , _ , T > ( event_loop, fut)
173
174
}
174
175
175
176
/// Run the event loop until the given Future completes
@@ -201,11 +202,12 @@ where
201
202
/// })
202
203
/// }
203
204
/// ```
204
- pub fn run < F > ( py : Python , fut : F ) -> PyResult < ( ) >
205
+ pub fn run < F , T > ( py : Python , fut : F ) -> PyResult < T >
205
206
where
206
- F : Future < Output = PyResult < ( ) > > + Send + ' static ,
207
+ F : Future < Output = PyResult < T > > + Send + ' static ,
208
+ T : Send + Sync + ' static ,
207
209
{
208
- generic:: run :: < AsyncStdRuntime , F > ( py, fut)
210
+ generic:: run :: < AsyncStdRuntime , F , T > ( py, fut)
209
211
}
210
212
211
213
/// Convert a Rust Future into a Python awaitable
@@ -273,11 +275,12 @@ where
273
275
/// )
274
276
/// }
275
277
/// ```
276
- pub fn future_into_py_with_locals < F > ( py : Python , locals : TaskLocals , fut : F ) -> PyResult < & PyAny >
278
+ pub fn future_into_py_with_locals < F , T > ( py : Python , locals : TaskLocals , fut : F ) -> PyResult < & PyAny >
277
279
where
278
- F : Future < Output = PyResult < PyObject > > + Send + ' static ,
280
+ F : Future < Output = PyResult < T > > + Send + ' static ,
281
+ T : IntoPy < PyObject > ,
279
282
{
280
- generic:: future_into_py_with_locals :: < AsyncStdRuntime , F > ( py, locals, fut)
283
+ generic:: future_into_py_with_locals :: < AsyncStdRuntime , F , T > ( py, locals, fut)
281
284
}
282
285
283
286
/// Convert a Rust Future into a Python awaitable
@@ -308,7 +311,7 @@ where
308
311
/// pyo3_asyncio::async_std::get_current_loop(py)?,
309
312
/// async move {
310
313
/// async_std::task::sleep(Duration::from_secs(secs)).await;
311
- /// Python::with_gil(|py| Ok( py.None()))
314
+ /// Ok( Python::with_gil(|py| py.None()))
312
315
/// }
313
316
/// )
314
317
/// }
@@ -344,15 +347,16 @@ where
344
347
/// let secs = secs.extract()?;
345
348
/// pyo3_asyncio::async_std::future_into_py(py, async move {
346
349
/// async_std::task::sleep(Duration::from_secs(secs)).await;
347
- /// Python::with_gil(|py| Ok(py.None() ))
350
+ /// Ok(( ))
348
351
/// })
349
352
/// }
350
353
/// ```
351
- pub fn future_into_py < F > ( py : Python , fut : F ) -> PyResult < & PyAny >
354
+ pub fn future_into_py < F , T > ( py : Python , fut : F ) -> PyResult < & PyAny >
352
355
where
353
- F : Future < Output = PyResult < PyObject > > + Send + ' static ,
356
+ F : Future < Output = PyResult < T > > + Send + ' static ,
357
+ T : IntoPy < PyObject > ,
354
358
{
355
- generic:: future_into_py :: < AsyncStdRuntime , _ > ( py, fut)
359
+ generic:: future_into_py :: < AsyncStdRuntime , _ , T > ( py, fut)
356
360
}
357
361
358
362
/// Convert a Rust Future into a Python awaitable
@@ -419,7 +423,7 @@ where
419
423
/// pyo3_asyncio::async_std::get_current_loop(py)?,
420
424
/// async move {
421
425
/// async_std::task::sleep(Duration::from_secs(*secs)).await;
422
- /// Python::with_gil(|py| Ok( py.None()))
426
+ /// Ok( Python::with_gil(|py| py.None()))
423
427
/// }
424
428
/// )?.into())
425
429
/// }
@@ -492,15 +496,16 @@ where
492
496
/// # #[cfg(not(all(feature = "async-std-runtime", feature = "attributes")))]
493
497
/// # fn main() {}
494
498
/// ```
495
- pub fn local_future_into_py_with_locals < F > (
499
+ pub fn local_future_into_py_with_locals < F , T > (
496
500
py : Python ,
497
501
locals : TaskLocals ,
498
502
fut : F ,
499
503
) -> PyResult < & PyAny >
500
504
where
501
- F : Future < Output = PyResult < PyObject > > + ' static ,
505
+ F : Future < Output = PyResult < T > > + ' static ,
506
+ T : IntoPy < PyObject > ,
502
507
{
503
- generic:: local_future_into_py_with_locals :: < AsyncStdRuntime , _ > ( py, locals, fut)
508
+ generic:: local_future_into_py_with_locals :: < AsyncStdRuntime , _ , T > ( py, locals, fut)
504
509
}
505
510
506
511
/// Convert a `!Send` Rust Future into a Python awaitable
@@ -583,7 +588,7 @@ where
583
588
/// let secs = Rc::new(secs);
584
589
/// pyo3_asyncio::async_std::local_future_into_py(py, async move {
585
590
/// async_std::task::sleep(Duration::from_secs(*secs)).await;
586
- /// Python::with_gil(|py| Ok(py.None() ))
591
+ /// Ok(( ))
587
592
/// })
588
593
/// }
589
594
///
@@ -601,11 +606,12 @@ where
601
606
/// # #[cfg(not(all(feature = "async-std-runtime", feature = "attributes")))]
602
607
/// # fn main() {}
603
608
/// ```
604
- pub fn local_future_into_py < F > ( py : Python , fut : F ) -> PyResult < & PyAny >
609
+ pub fn local_future_into_py < F , T > ( py : Python , fut : F ) -> PyResult < & PyAny >
605
610
where
606
- F : Future < Output = PyResult < PyObject > > + ' static ,
611
+ F : Future < Output = PyResult < T > > + ' static ,
612
+ T : IntoPy < PyObject > ,
607
613
{
608
- generic:: local_future_into_py :: < AsyncStdRuntime , _ > ( py, fut)
614
+ generic:: local_future_into_py :: < AsyncStdRuntime , _ , T > ( py, fut)
609
615
}
610
616
611
617
/// Convert a `!Send` Rust Future into a Python awaitable
0 commit comments