Struct pyo3::coroutine::Coroutine

source ·
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§

source§

impl Coroutine

source§

impl Coroutine

source

#[doc(hidden)] pub const _PYO3_DEF: AddClassToModule<Self> = _

source§

impl Coroutine

source

pub(crate) fn new<F, T, E>( name: Option<Py<PyString>>, qualname_prefix: Option<&'static str>, throw_callback: Option<ThrowCallback>, future: F ) -> Self
where F: Future<Output = Result<T, E>> + Send + 'static, T: IntoPy<PyObject>, E: Into<PyErr>,

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

source

fn poll( &mut self, py: Python<'_>, throw: Option<PyObject> ) -> PyResult<PyObject>

source§

impl Coroutine

source

fn __name__(&self, py: Python<'_>) -> PyResult<Py<PyString>>

source

fn __qualname__(&self, py: Python<'_>) -> PyResult<Py<PyString>>

source

fn send( &mut self, py: Python<'_>, _value: &Bound<'_, PyAny> ) -> PyResult<PyObject>

source

fn throw(&mut self, py: Python<'_>, exc: PyObject) -> PyResult<PyObject>

source

fn close(&mut self)

source

fn __await__(self_: Py<Self>) -> Py<Self>

source

fn __next__(&mut self, py: Python<'_>) -> PyResult<PyObject>

source§

impl Coroutine

Trait Implementations§

source§

impl HasPyGilRef for Coroutine

§

type AsRefTarget = PyCell<Coroutine>

Utility type to make Py::as_ref work.
source§

impl IntoPy<Py<PyAny>> for Coroutine

source§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
source§

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 PyClass for Coroutine

§

type Frozen = False

Whether the pyclass is frozen. Read more
source§

impl PyClassImpl for Coroutine

source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type BaseType = PyAny

Base class
§

type ThreadChecker = SendablePyClass<Coroutine>

This handles following two situations: Read more
§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
source§

fn items_iter() -> PyClassItemsIter

source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

source§

fn dict_offset() -> Option<Py_ssize_t>

source§

fn weaklist_offset() -> Option<Py_ssize_t>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a Coroutine

§

type Holder = Option<PyRef<'py, Coroutine>>

source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder ) -> PyResult<Self>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut Coroutine

§

type Holder = Option<PyRefMut<'py, Coroutine>>

source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder ) -> PyResult<Self>

source§

impl PyMethods<Coroutine> for PyClassImplCollector<Coroutine>

source§

fn py_methods(self) -> &'static PyClassItems

Available on non-crate feature multiple-pymethods only.
source§

impl PyTypeInfo for Coroutine

source§

const NAME: &'static str = "Coroutine"

Class name.
source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
source§

fn type_object(py: Python<'_>) -> &PyType

👎Deprecated since 0.21.0: PyTypeInfo::type_object will be replaced by PyTypeInfo::type_object_bound in a future PyO3 version
Returns the safe abstraction over the type object.
source§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
source§

fn is_type_of(object: &PyAny) -> bool

👎Deprecated since 0.21.0: PyTypeInfo::is_type_of will be replaced by PyTypeInfo::is_type_of_bound in a future PyO3 version
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

Checks if object is an instance of this type or a subclass of this type.
source§

fn is_exact_type_of(object: &PyAny) -> bool

👎Deprecated since 0.21.0: PyTypeInfo::is_exact_type_of will be replaced by PyTypeInfo::is_exact_type_of_bound in a future PyO3 version
Checks if object is an instance of this type.
source§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
source§

impl DerefToPyAny for Coroutine

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AssertNotZeroSized for T

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
source§

impl<T> IntoPyCallbackOutput<*mut PyObject> for T
where T: IntoPy<Py<PyAny>>,

source§

impl<T> IntoPyCallbackOutput<Py<PyAny>> for T
where T: IntoPy<Py<PyAny>>,

source§

fn convert(self, py: Python<'_>) -> Result<Py<PyAny>, PyErr>

source§

impl<T, U> IntoPyCallbackOutput<PyClassInitializer<T>> for U
where T: PyClass, U: Into<PyClassInitializer<T>>,

source§

impl<T> OkWrap<T> for T
where T: IntoPy<Py<PyAny>>,

source§

impl<T> PyClassBaseType for T
where T: PyClass,

source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

source§

const NAME: &'static str = const NAME: &'static str = <T as PyTypeInfo>::NAME;

Name of self. This is used in error messages, for example.
source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
source§

impl<T> SizedTypeProperties for T

source§

#[doc(hidden)] const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
source§

impl<T> SomeWrap<T> for T

source§

fn wrap(self) -> Option<T>

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Ungil for T
where T: Send,

⚠️ Internal Docs ⚠️ Not Public API 👉 Official Docs Here