pub struct Coroutine(/* private fields */);
Expand description

Python coroutine wrapping a PyFuture.

Implementations§

source§

impl Coroutine

source

pub fn new(future: Pin<Box<dyn PyFuture>>, throw: Option<ThrowCallback>) -> Self

Wrap a boxed future in to a Python coroutine.

If throw callback is provided:

  • coroutine throw method will call it with the passed exception before polling;
  • coroutine close method will call it with None before polling and dropping the future. If throw callback is not provided, the future will dropped without additional poll.
source

pub fn from_future(future: impl PyFuture + 'static) -> Self

Wrap a generic future into a Python coroutine.

Trait Implementations§

source§

impl IntoPy<Py<PyAny>> for Coroutine

source§

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

Performs the conversion.
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 Layout = PyCell<Coroutine>

Layout
§

type BaseType = PyAny

Base class
§

type ThreadChecker = ThreadCheckerStub<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<isize>

source§

fn weaklist_offset() -> Option<isize>

source§

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

§

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

source§

fn extract(obj: &'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: &'py PyAny, holder: &'a mut Self::Holder) -> PyResult<Self>

source§

impl PyMethods<Coroutine> for PyClassImplCollector<Coroutine>

source§

fn py_methods(self) -> &'static PyClassItems

source§

impl PyTypeInfo for Coroutine

§

type AsRefTarget = PyCell<Coroutine>

Utility type to make Py::as_ref work.
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

Returns the safe abstraction over the type object.
source§

fn is_type_of(object: &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

Checks if object is an instance of this type.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> OkWrap<T> for Twhere T: IntoPy<Py<PyAny>>,

§

type Error = PyErr

source§

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

source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere T: Send,