pub trait PyClassImpl: Sized + 'static {
type Layout: PyClassObjectLayout<Self>;
type BaseType: PyTypeInfo + PyClassBaseType;
type PyClassMutability: PyClassMutability + GetBorrowChecker<Self>;
type Dict: PyClassDict;
type WeakRef: PyClassWeakRef;
type BaseNativeType: PyTypeInfo;
type ThreadChecker: PyClassThreadChecker<Self>;
Show 8 associated constants and 4 methods
const MODULE: Option<&'static str>;
const RAW_DOC: &'static CStr;
const DOC: &'static CStr;
const IS_BASETYPE: bool = false;
const IS_SUBCLASS: bool = false;
const IS_MAPPING: bool = false;
const IS_SEQUENCE: bool = false;
const IS_IMMUTABLE_TYPE: bool = false;
// Required methods
fn items_iter() -> PyClassItemsIter ⓘ;
fn lazy_type_object() -> &'static LazyTypeObject<Self>;
// Provided methods
fn dict_offset() -> Option<PyObjectOffset> { ... }
fn weaklist_offset() -> Option<PyObjectOffset> { ... }
}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 Constants§
Sourceconst MODULE: Option<&'static str>
const MODULE: Option<&'static str>
Module which the class will be associated with.
(Currently defaults to builtins if unset, this will likely be improved in the future, it
may also be removed when passing module objects in class init.)
Provided Associated Constants§
Sourceconst IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
#[pyclass(subclass)]
Sourceconst IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
#[pyclass(extends=…)]
Sourceconst IS_MAPPING: bool = false
const IS_MAPPING: bool = false
#[pyclass(mapping)]
Sourceconst IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
#[pyclass(sequence)]
Sourceconst IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
#[pyclass(immutable_type)]
Required Associated Types§
Sourcetype Layout: PyClassObjectLayout<Self>
type Layout: PyClassObjectLayout<Self>
Description of how this class is laid out in memory
Sourcetype BaseType: PyTypeInfo + PyClassBaseType
type BaseType: PyTypeInfo + PyClassBaseType
Base class
Sourcetype PyClassMutability: PyClassMutability + GetBorrowChecker<Self>
type PyClassMutability: PyClassMutability + GetBorrowChecker<Self>
Immutable or mutable
Sourcetype Dict: PyClassDict
type Dict: PyClassDict
Specify this class has #[pyclass(dict)] or not.
Sourcetype WeakRef: PyClassWeakRef
type WeakRef: PyClassWeakRef
Specify this class has #[pyclass(weakref)] or not.
Sourcetype BaseNativeType: PyTypeInfo
type BaseNativeType: PyTypeInfo
The closest native ancestor. This is PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.
Sourcetype ThreadChecker: PyClassThreadChecker<Self>
type ThreadChecker: PyClassThreadChecker<Self>
This handles following two situations:
- In case
TisSend, stubThreadCheckeris used and does nothing. This implementation is used by default. Compile fails ifT: !Send. - In case
Tis!Send,ThreadCheckerpanics whenTis accessed by another thread. This implementation is used when#[pyclass(unsendable)]is given. Panicking makes it safe to exposeT: !Sendto the Python interpreter, where all objects can be accessed by multiple threads bythreadingmodule.
Required Methods§
fn items_iter() -> PyClassItemsIter ⓘ
fn lazy_type_object() -> &'static LazyTypeObject<Self>
Provided Methods§
Sourcefn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
Used to provide the dictoffset slot (equivalent to tp_dictoffset)
Sourcefn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Used to provide the weaklistoffset slot (equivalent to tp_weaklistoffset
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl PyClassImpl for Coroutine
Available on crate feature experimental-async only.
impl PyClassImpl for Coroutine
experimental-async only.