Skip to main content

PyPayload

Trait PyPayload 

Source
pub trait PyPayload:
    MaybeTraverse
    + PyThreadingConstraint
    + Sized
    + 'static {
    const PAYLOAD_TYPE_ID: TypeId = _;
    const HAS_FREELIST: bool = false;
    const MAX_FREELIST: usize = 0;

    // Required method
    fn class(ctx: &Context) -> &'static Py<PyType>;

    // Provided methods
    unsafe fn validate_downcastable_from(_obj: &PyObject) -> bool { ... }
    fn try_downcast_from(obj: &PyObject, vm: &VirtualMachine) -> PyResult<()> { ... }
    unsafe fn freelist_push(_obj: *mut PyObject) -> bool { ... }
    unsafe fn freelist_pop(_payload: &Self) -> Option<NonNull<PyObject>> { ... }
    fn into_pyobject(self, vm: &VirtualMachine) -> PyObjectRef
       where Self: Debug { ... }
    fn _into_ref(self, cls: PyTypeRef, ctx: &Context) -> PyRef<Self>
       where Self: Debug { ... }
    fn into_exact_ref(self, ctx: &Context) -> PyRefExact<Self>
       where Self: Debug { ... }
    fn into_ref(self, ctx: &Context) -> PyRef<Self>
       where Self: Debug { ... }
    fn into_ref_with_type(
        self,
        vm: &VirtualMachine,
        cls: PyTypeRef,
    ) -> PyResult<PyRef<Self>>
       where Self: Debug { ... }
}

Provided Associated Constants§

Source

const PAYLOAD_TYPE_ID: TypeId = _

Source

const HAS_FREELIST: bool = false

Whether this type has a freelist. Types with freelists require immediate (non-deferred) GC untracking during dealloc to prevent race conditions when the object is reused.

Source

const MAX_FREELIST: usize = 0

Maximum number of objects to keep in the freelist.

Required Methods§

Source

fn class(ctx: &Context) -> &'static Py<PyType>

Provided Methods§

Source

unsafe fn validate_downcastable_from(_obj: &PyObject) -> bool

§Safety

This function should only be called if payload_type_id matches the type of obj.

Source

fn try_downcast_from(obj: &PyObject, vm: &VirtualMachine) -> PyResult<()>

Source

unsafe fn freelist_push(_obj: *mut PyObject) -> bool

Try to push a dead object onto this type’s freelist for reuse. Returns true if the object was stored (caller must NOT free the memory). Called before tp_clear, so the payload is still intact.

§Safety

obj must be a valid pointer to a PyInner<Self> with refcount 0. The payload is still initialized and can be read for bucket selection.

Source

unsafe fn freelist_pop(_payload: &Self) -> Option<NonNull<PyObject>>

Try to pop a pre-allocated object from this type’s freelist. The returned pointer still has the old payload; the caller must reinitialize ref_count, gc_bits, and payload.

§Safety

The returned pointer (if Some) must point to a valid PyInner<Self> whose payload is still initialized from a previous allocation. The caller will drop and overwrite payload before reuse.

Source

fn into_pyobject(self, vm: &VirtualMachine) -> PyObjectRef
where Self: Debug,

Source

fn _into_ref(self, cls: PyTypeRef, ctx: &Context) -> PyRef<Self>
where Self: Debug,

Source

fn into_exact_ref(self, ctx: &Context) -> PyRefExact<Self>
where Self: Debug,

Source

fn into_ref(self, ctx: &Context) -> PyRef<Self>
where Self: Debug,

Source

fn into_ref_with_type( self, vm: &VirtualMachine, cls: PyTypeRef, ) -> PyResult<PyRef<Self>>
where Self: Debug,

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 PyPayload for PyArithmeticError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyAssertionError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyAsyncGen

Source§

impl PyPayload for PyAttributeError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyBaseException

Source§

impl PyPayload for PyBaseExceptionGroup

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyBaseException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyBaseObject

Source§

impl PyPayload for PyBlockingIOError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyBool

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyInt as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyBoundMethod

Source§

impl PyPayload for PyBrokenPipeError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyConnectionError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyBufferError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyByteArray

Source§

impl PyPayload for PyBytes

Source§

impl PyPayload for PyBytesWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyCallableIterator

Source§

impl PyPayload for PyCapsule

Source§

impl PyPayload for PyChildProcessError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyClassMethod

Source§

impl PyPayload for PyCode

Source§

impl PyPayload for PyComplex

Source§

impl PyPayload for PyConnectionAbortedError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyConnectionError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyConnectionError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyConnectionRefusedError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyConnectionError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyConnectionResetError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyConnectionError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyCoroutine

Source§

impl PyPayload for PyDeprecationWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyDict

Source§

impl PyPayload for PyEOFError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyEllipsis

Source§

impl PyPayload for PyEncodingWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyEnumerate

Source§

impl PyPayload for PyException

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyBaseException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyFileExistsError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyFileNotFoundError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyFilter

Source§

impl PyPayload for PyFloat

Source§

impl PyPayload for PyFloatingPointError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyArithmeticError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyFrozenSet

Source§

impl PyPayload for PyFunction

Source§

impl PyPayload for PyFutureWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyGenerator

Source§

impl PyPayload for PyGeneratorExit

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyBaseException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyGenericAlias

Source§

impl PyPayload for PyGetSet

Source§

impl PyPayload for PyImportError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyImportWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyIncompleteInputError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PySyntaxError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyIndentationError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PySyntaxError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyIndexError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyLookupError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyInt

Source§

impl PyPayload for PyInterpolation

Source§

impl PyPayload for PyInterruptedError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyIsADirectoryError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyKeyError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyLookupError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyKeyboardInterrupt

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyBaseException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyList

Source§

impl PyPayload for PyLookupError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyMap

Source§

impl PyPayload for PyMappingProxy

Source§

impl PyPayload for PyMemoryError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyMemoryView

Source§

impl PyPayload for PyModule

Source§

impl PyPayload for PyModuleNotFoundError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyImportError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyNameError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyNamespace

Source§

impl PyPayload for PyNone

Source§

impl PyPayload for PyNotADirectoryError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyNotImplemented

Source§

impl PyPayload for PyNotImplementedError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyRuntimeError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyOSError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyOverflowError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyArithmeticError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyPendingDeprecationWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyPermissionError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyProcessLookupError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyProperty

Source§

impl PyPayload for PyPythonFinalizationError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyRuntimeError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyRange

Source§

impl PyPayload for PyRecursionError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyRuntimeError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyReferenceError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyResourceWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyRuntimeError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyRuntimeWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PySequenceIterator

Source§

impl PyPayload for PySet

Source§

impl PyPayload for PySlice

Source§

impl PyPayload for PyStaticMethod

Source§

impl PyPayload for PyStopAsyncIteration

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyStopIteration

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyStr

Source§

impl PyPayload for PySuper

Source§

impl PyPayload for PySyntaxError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PySyntaxWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PySystemError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PySystemExit

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyBaseException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyTabError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyIndentationError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyTemplate

Source§

impl PyPayload for PyTemplateIter

Source§

impl PyPayload for PyTimeoutError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyOSError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyTraceback

Source§

impl PyPayload for PyTuple

Source§

impl PyPayload for PyType

Source§

impl PyPayload for PyTypeError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUnboundLocalError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyNameError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUnicodeDecodeError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyUnicodeError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUnicodeEncodeError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyUnicodeError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUnicodeError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyValueError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUnicodeTranslateError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyUnicodeError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUnicodeWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUnion

Source§

impl PyPayload for PyUserWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyWarning as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyUtf8Str

Source§

impl PyPayload for PyValueError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyWarning

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyException as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyWeak

Source§

impl PyPayload for PyWeakProxy

Source§

impl PyPayload for PyZeroDivisionError

Source§

const PAYLOAD_TYPE_ID: TypeId = <PyArithmeticError as ::rustpython_vm::PyPayload>::PAYLOAD_TYPE_ID

Source§

impl PyPayload for PyZip

Source§

impl PyPayload for Frame

Source§

impl PyPayload for HeapMethodDef

Source§

impl PyPayload for VecBuffer

Source§

impl PyPayload for Generic

Source§

impl PyPayload for NoDefault

Source§

impl PyPayload for ParamSpec

Source§

impl PyPayload for ParamSpecArgs

Source§

impl PyPayload for ParamSpecKwargs

Source§

impl PyPayload for TypeVar

Source§

impl PyPayload for TypeVarTuple