pub struct Coroutine {
name: Option<Py<PyString>>,
qualname_prefix: Option<&'static str>,
throw_callback: Option<ThrowCallback>,
future: Option<Pin<Box<dyn Future<Output = PyResult<PyObject>> + Send>>>,
waker: Option<Arc<AsyncioWaker>>,
}
Available on crate feature
experimental-async
only.Expand description
Python coroutine wrapping a Future
.
Fields§
§name: Option<Py<PyString>>
§qualname_prefix: Option<&'static str>
§throw_callback: Option<ThrowCallback>
§future: Option<Pin<Box<dyn Future<Output = PyResult<PyObject>> + Send>>>
§waker: Option<Arc<AsyncioWaker>>
Implementations§
impl Coroutine
impl Coroutine
Source§impl Coroutine
impl Coroutine
Sourcepub(crate) fn new<'py, F, T, E>(
name: Option<Bound<'py, PyString>>,
qualname_prefix: Option<&'static str>,
throw_callback: Option<ThrowCallback>,
future: F,
) -> Self
pub(crate) fn new<'py, F, T, E>( name: Option<Bound<'py, PyString>>, qualname_prefix: Option<&'static str>, throw_callback: Option<ThrowCallback>, future: F, ) -> Self
Wrap a future into a Python coroutine.
Coroutine send
polls the wrapped future, ignoring the value passed
(should always be None
anyway).
Coroutine
throw` drop the wrapped future and reraise the exception passed
fn poll( &mut self, py: Python<'_>, throw: Option<PyObject>, ) -> PyResult<PyObject>
Source§impl Coroutine
impl Coroutine
fn __name__(&self, py: Python<'_>) -> PyResult<Py<PyString>>
fn __qualname__<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyString>>
fn send( &mut self, py: Python<'_>, _value: &Bound<'_, PyAny>, ) -> PyResult<PyObject>
fn throw(&mut self, py: Python<'_>, exc: PyObject) -> PyResult<PyObject>
fn close(&mut self)
fn __await__(self_: Py<Self>) -> Py<Self>
fn __next__(&mut self, py: Python<'_>) -> PyResult<PyObject>
Source§impl Coroutine
impl Coroutine
unsafe fn __pymethod_get___name____( py: Python<'_>, _slf: *mut PyObject, ) -> PyResult<*mut PyObject>
unsafe fn __pymethod_get___qualname____( py: Python<'_>, _slf: *mut PyObject, ) -> PyResult<*mut PyObject>
unsafe fn __pymethod_send__<'py>( py: Python<'py>, _slf: *mut PyObject, _args: *const *mut PyObject, _nargs: Py_ssize_t, _kwnames: *mut PyObject, ) -> PyResult<*mut PyObject>
unsafe fn __pymethod_throw__<'py>( py: Python<'py>, _slf: *mut PyObject, _args: *const *mut PyObject, _nargs: Py_ssize_t, _kwnames: *mut PyObject, ) -> PyResult<*mut PyObject>
unsafe fn __pymethod_close__<'py>( py: Python<'py>, _slf: *mut PyObject, ) -> PyResult<*mut PyObject>
unsafe fn __pymethod___await____( py: Python<'_>, _raw_slf: *mut PyObject, ) -> PyResult<*mut PyObject>
unsafe fn __pymethod___next____( py: Python<'_>, _raw_slf: *mut PyObject, ) -> PyResult<*mut PyObject>
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for Coroutine
impl<'py> IntoPyObject<'py> for Coroutine
Source§type Output = Bound<'py, <Coroutine as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Coroutine as IntoPyObject<'py>>::Target>
The smart pointer type to use. Read more
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Performs the conversion.
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
Available on crate feature
experimental-inspect
only.Extracts the type hint information for this type when it appears as a return value. Read more
Source§impl PyClassImpl for Coroutine
impl PyClassImpl for Coroutine
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
#[pyclass(subclass)]
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
#[pyclass(extends=…)]
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
#[pyclass(mapping)]
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
#[pyclass(sequence)]
Source§type ThreadChecker = SendablePyClass<Coroutine>
type ThreadChecker = SendablePyClass<Coroutine>
This handles following two situations: Read more
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Immutable or mutable
Source§type Dict = PyClassDummySlot
type Dict = PyClassDummySlot
Specify this class has
#[pyclass(dict)]
or not.Source§type WeakRef = PyClassDummySlot
type WeakRef = PyClassDummySlot
Specify this class has
#[pyclass(weakref)]
or not.Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter ⓘ
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<Py_ssize_t>
fn weaklist_offset() -> Option<Py_ssize_t>
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a Coroutine
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a Coroutine
Source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut Coroutine
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut Coroutine
Source§impl PyMethods<Coroutine> for PyClassImplCollector<Coroutine>
impl PyMethods<Coroutine> for PyClassImplCollector<Coroutine>
Source§fn py_methods(self) -> &'static PyClassItems
fn py_methods(self) -> &'static PyClassItems
Available on non-crate feature
multiple-pymethods
only.Source§impl PyTypeInfo for Coroutine
impl PyTypeInfo for Coroutine
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Returns the PyTypeObject instance for this type.
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
Returns the safe abstraction over the type object.
Source§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
👎Deprecated since 0.23.0: renamed to
PyTypeInfo::type_object
Deprecated name for
PyTypeInfo::type_object
.Source§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
Checks if
object
is an instance of this type or a subclass of this type.Source§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
👎Deprecated since 0.23.0: renamed to
PyTypeInfo::is_type_of
Deprecated name for
PyTypeInfo::is_type_of
.Source§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
Checks if
object
is an instance of this type.Source§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
👎Deprecated since 0.23.0: renamed to
PyTypeInfo::is_exact_type_of
Deprecated name for
PyTypeInfo::is_exact_type_of
.impl DerefToPyAny for Coroutine
impl Sync for Coroutine
Auto Trait Implementations§
impl Freeze for Coroutine
impl !RefUnwindSafe for Coroutine
impl Send for Coroutine
impl Unpin for Coroutine
impl !UnwindSafe for Coroutine
Blanket Implementations§
Source§impl<T> AssertNotZeroSized for T
impl<T> AssertNotZeroSized for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, U> IntoPyCallbackOutput<'_, PyClassInitializer<T>> for U
impl<T, U> IntoPyCallbackOutput<'_, PyClassInitializer<T>> for U
Source§impl<'py, T> IntoPyCallbackOutput<'py, *mut PyObject> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyCallbackOutput<'py, *mut PyObject> for Twhere
T: IntoPyObject<'py>,
Source§impl<'py, T> IntoPyCallbackOutput<'py, Py<PyAny>> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyCallbackOutput<'py, Py<PyAny>> for Twhere
T: IntoPyObject<'py>,
Source§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>>
fn into_bound_py_any(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>>
Converts
self
into an owned Python object, dropping type information.