Trait pyo3::impl_::pyclass::PyClassImpl

source ·
pub trait PyClassImpl: Sized + 'static {
    type BaseType: PyTypeInfo + PyClassBaseType;
    type PyClassMutability: PyClassMutability + GetBorrowChecker<Self>;
    type Dict: PyClassDict;
    type WeakRef: PyClassWeakRef;
    type BaseNativeType: PyTypeInfo + PyNativeType;
    type ThreadChecker: PyClassThreadChecker<Self>;

    const IS_BASETYPE: bool = false;
    const IS_SUBCLASS: bool = false;
    const IS_MAPPING: bool = false;
    const IS_SEQUENCE: bool = false;

    // Required methods
    fn doc(py: Python<'_>) -> PyResult<&'static CStr>;
    fn items_iter() -> PyClassItemsIter ;
    fn lazy_type_object() -> &'static LazyTypeObject<Self>;

    // Provided methods
    fn dict_offset() -> Option<Py_ssize_t> { ... }
    fn weaklist_offset() -> Option<Py_ssize_t> { ... }
}
Expand description

Implements the underlying functionality of #[pyclass], assembled by various proc macros.

Users are discouraged from implementing this trait manually; it is a PyO3 implementation detail and may be changed at any time.

Required Associated Types§

source

type BaseType: PyTypeInfo + PyClassBaseType

Base class

source

type PyClassMutability: PyClassMutability + GetBorrowChecker<Self>

Immutable or mutable

source

type Dict: PyClassDict

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

source

type WeakRef: PyClassWeakRef

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

source

type BaseNativeType: PyTypeInfo + PyNativeType

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

source

type ThreadChecker: PyClassThreadChecker<Self>

This handles following two situations:

  1. In case T is Send, stub ThreadChecker is used and does nothing. This implementation is used by default. Compile fails if T: !Send.
  2. In case T is !Send, ThreadChecker panics when T is accessed by another thread. This implementation is used when #[pyclass(unsendable)] is given. Panicking makes it safe to expose T: !Send to the Python interpreter, where all objects can be accessed by multiple threads by threading module.

Provided Associated Constants§

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)]

Required Methods§

source

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

Rendered class doc

source

fn items_iter() -> PyClassItemsIter

source

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

Provided Methods§

Object Safety§

This trait is not object safe.

Implementors§

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