Skip to main content

PySubclass

Trait PySubclass 

Source
pub trait PySubclass: PyPayload {
    type Base: PyPayload;

    // Required method
    fn as_base(&self) -> &Self::Base;
}
Expand description

Trait for Python subclasses that can provide a reference to their base type.

This trait is automatically implemented by the #[pyclass] macro when base = SomeType is specified. It provides safe reference access to the base type’s payload.

For subclasses with #[repr(transparent)] which enables ownership transfer via into_base().

Required Associated Types§

Required Methods§

Source

fn as_base(&self) -> &Self::Base

Returns a reference to the base type’s payload.

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

Source§

impl PySubclass for PyAssertionError

Source§

impl PySubclass for PyAttributeError

Source§

impl PySubclass for PyBaseExceptionGroup

Source§

impl PySubclass for PyBlockingIOError

Source§

impl PySubclass for PyBool

Source§

impl PySubclass for PyBrokenPipeError

Source§

impl PySubclass for PyBufferError

Source§

impl PySubclass for PyBytesWarning

Source§

impl PySubclass for PyChildProcessError

Source§

impl PySubclass for PyConnectionAbortedError

Source§

impl PySubclass for PyConnectionError

Source§

impl PySubclass for PyConnectionRefusedError

Source§

impl PySubclass for PyConnectionResetError

Source§

impl PySubclass for PyDeprecationWarning

Source§

impl PySubclass for PyEOFError

Source§

impl PySubclass for PyEncodingWarning

Source§

impl PySubclass for PyException

Source§

impl PySubclass for PyFileExistsError

Source§

impl PySubclass for PyFileNotFoundError

Source§

impl PySubclass for PyFloatingPointError

Source§

impl PySubclass for PyFutureWarning

Source§

impl PySubclass for PyGeneratorExit

Source§

impl PySubclass for PyImportError

Source§

impl PySubclass for PyImportWarning

Source§

impl PySubclass for PyIncompleteInputError

Source§

impl PySubclass for PyIndentationError

Source§

impl PySubclass for PyIndexError

Source§

impl PySubclass for PyInterruptedError

Source§

impl PySubclass for PyIsADirectoryError

Source§

impl PySubclass for PyKeyError

Source§

impl PySubclass for PyKeyboardInterrupt

Source§

impl PySubclass for PyLookupError

Source§

impl PySubclass for PyMemoryError

Source§

impl PySubclass for PyModuleNotFoundError

Source§

impl PySubclass for PyNameError

Source§

impl PySubclass for PyNotADirectoryError

Source§

impl PySubclass for PyNotImplementedError

Source§

impl PySubclass for PyOSError

Source§

impl PySubclass for PyOverflowError

Source§

impl PySubclass for PyPendingDeprecationWarning

Source§

impl PySubclass for PyPermissionError

Source§

impl PySubclass for PyProcessLookupError

Source§

impl PySubclass for PyPythonFinalizationError

Source§

impl PySubclass for PyRecursionError

Source§

impl PySubclass for PyReferenceError

Source§

impl PySubclass for PyResourceWarning

Source§

impl PySubclass for PyRuntimeError

Source§

impl PySubclass for PyRuntimeWarning

Source§

impl PySubclass for PyStopAsyncIteration

Source§

impl PySubclass for PyStopIteration

Source§

impl PySubclass for PySyntaxError

Source§

impl PySubclass for PySyntaxWarning

Source§

impl PySubclass for PySystemError

Source§

impl PySubclass for PySystemExit

Source§

impl PySubclass for PyTabError

Source§

impl PySubclass for PyTimeoutError

Source§

impl PySubclass for PyTypeError

Source§

impl PySubclass for PyUnboundLocalError

Source§

impl PySubclass for PyUnicodeDecodeError

Source§

impl PySubclass for PyUnicodeEncodeError

Source§

impl PySubclass for PyUnicodeError

Source§

impl PySubclass for PyUnicodeTranslateError

Source§

impl PySubclass for PyUnicodeWarning

Source§

impl PySubclass for PyUserWarning

Source§

impl PySubclass for PyValueError

Source§

impl PySubclass for PyWarning

Source§

impl PySubclass for PyZeroDivisionError