pub struct Coroutine(/* private fields */);
Expand description
Python coroutine wrapping a PyFuture
.
Implementations§
Source§impl Coroutine
impl Coroutine
Sourcepub fn new(future: Pin<Box<dyn PyFuture>>, throw: Option<ThrowCallback>) -> Self
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 withNone
before polling and dropping the future. Ifthrow
callback is not provided, the future will dropped without additional poll.
Sourcepub fn from_future(future: impl PyFuture + 'static) -> Self
pub fn from_future(future: impl PyFuture + 'static) -> Self
Wrap a generic future into a Python coroutine.
Trait Implementations§
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 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<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyMethods<Coroutine> for PyClassImplCollector<Coroutine>
impl PyMethods<Coroutine> for PyClassImplCollector<Coroutine>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for Coroutine
impl PyTypeInfo for Coroutine
Source§type AsRefTarget = PyCell<Coroutine>
type AsRefTarget = PyCell<Coroutine>
Utility type to make Py::as_ref work.
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<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
Returns the safe abstraction over the type object.
Source§fn is_type_of(object: &PyAny) -> bool
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
fn is_exact_type_of(object: &PyAny) -> bool
Checks if
object
is an instance of this type.Auto Trait Implementations§
impl Freeze for Coroutine
impl !RefUnwindSafe for Coroutine
impl Send for Coroutine
impl !Sync for Coroutine
impl Unpin for Coroutine
impl !UnwindSafe for Coroutine
Blanket Implementations§
Source§impl<T> AllowThreadsExt for T
impl<T> AllowThreadsExt for T
fn allow_threads(self) -> AllowThreads<Self> ⓘ
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