devela::_dep::pyo3

Trait PyTypeInfo

pub unsafe trait PyTypeInfo: Sized {
    const NAME: &'static str;
    const MODULE: Option<&'static str>;

    // Required method
    fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject;

    // Provided methods
    fn type_object(py: Python<'_>) -> Bound<'_, PyType> { ... }
    fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType> { ... }
    fn is_type_of(object: &Bound<'_, PyAny>) -> bool { ... }
    fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool { ... }
    fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool { ... }
    fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool { ... }
}
Available on crate features dep_pyo3 and std only.
Expand description

Python type information. All Python native types (e.g., PyDict) and #[pyclass] structs implement this trait.

This trait is marked unsafe because:

  • specifying the incorrect layout can lead to memory errors
  • the return value of type_object must always point to the same PyTypeObject instance

It is safely implemented by the pyclass macro.

§Safety

Implementations must provide an implementation for type_object_raw which infallibly produces a non-null pointer to the corresponding Python type object.

Required Associated Constants§

const NAME: &'static str

Class name.

const MODULE: Option<&'static str>

Module name, if any.

Required Methods§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.

Provided Methods§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

👎Deprecated since 0.23.0: renamed to PyTypeInfo::type_object

Deprecated name for PyTypeInfo::type_object.

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_type_of

Deprecated name for PyTypeInfo::is_type_of.

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

👎Deprecated since 0.23.0: renamed to PyTypeInfo::is_exact_type_of

Deprecated name for PyTypeInfo::is_exact_type_of.

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§

§

impl PyTypeInfo for CancelledError

§

const NAME: &'static str = "CancelledError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for IncompleteReadError

§

const NAME: &'static str = "IncompleteReadError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for InvalidStateError

§

const NAME: &'static str = "InvalidStateError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for LimitOverrunError

§

const NAME: &'static str = "LimitOverrunError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for QueueEmpty

§

const NAME: &'static str = "QueueEmpty"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for QueueFull

§

const NAME: &'static str = "QueueFull"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for TimeoutError

§

const NAME: &'static str = "TimeoutError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for gaierror

§

const NAME: &'static str = "gaierror"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for herror

§

const NAME: &'static str = "herror"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for timeout

§

const NAME: &'static str = "timeout"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyArithmeticError

§

const NAME: &'static str = "PyArithmeticError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyAssertionError

§

const NAME: &'static str = "PyAssertionError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyAttributeError

§

const NAME: &'static str = "PyAttributeError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyBaseException

§

const NAME: &'static str = "PyBaseException"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyBlockingIOError

§

const NAME: &'static str = "PyBlockingIOError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyBrokenPipeError

§

const NAME: &'static str = "PyBrokenPipeError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyBufferError

§

const NAME: &'static str = "PyBufferError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyBytesWarning

§

const NAME: &'static str = "PyBytesWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyChildProcessError

§

const NAME: &'static str = "PyChildProcessError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyConnectionAbortedError

§

const NAME: &'static str = "PyConnectionAbortedError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyConnectionError

§

const NAME: &'static str = "PyConnectionError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyConnectionRefusedError

§

const NAME: &'static str = "PyConnectionRefusedError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyConnectionResetError

§

const NAME: &'static str = "PyConnectionResetError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDeprecationWarning

§

const NAME: &'static str = "PyDeprecationWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyEOFError

§

const NAME: &'static str = "PyEOFError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyEncodingWarning

§

const NAME: &'static str = "PyEncodingWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyEnvironmentError

§

const NAME: &'static str = "PyEnvironmentError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyException

§

const NAME: &'static str = "PyException"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyFileExistsError

§

const NAME: &'static str = "PyFileExistsError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyFileNotFoundError

§

const NAME: &'static str = "PyFileNotFoundError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyFloatingPointError

§

const NAME: &'static str = "PyFloatingPointError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyFutureWarning

§

const NAME: &'static str = "PyFutureWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyGeneratorExit

§

const NAME: &'static str = "PyGeneratorExit"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyIOError

§

const NAME: &'static str = "PyIOError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyImportError

§

const NAME: &'static str = "PyImportError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyImportWarning

§

const NAME: &'static str = "PyImportWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyIndexError

§

const NAME: &'static str = "PyIndexError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyInterruptedError

§

const NAME: &'static str = "PyInterruptedError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyIsADirectoryError

§

const NAME: &'static str = "PyIsADirectoryError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyKeyError

§

const NAME: &'static str = "PyKeyError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyKeyboardInterrupt

§

const NAME: &'static str = "PyKeyboardInterrupt"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyLookupError

§

const NAME: &'static str = "PyLookupError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyMemoryError

§

const NAME: &'static str = "PyMemoryError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyModuleNotFoundError

§

const NAME: &'static str = "PyModuleNotFoundError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyNameError

§

const NAME: &'static str = "PyNameError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyNotADirectoryError

§

const NAME: &'static str = "PyNotADirectoryError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyNotImplementedError

§

const NAME: &'static str = "PyNotImplementedError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyOSError

§

const NAME: &'static str = "PyOSError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyOverflowError

§

const NAME: &'static str = "PyOverflowError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyPendingDeprecationWarning

§

const NAME: &'static str = "PyPendingDeprecationWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyPermissionError

§

const NAME: &'static str = "PyPermissionError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyProcessLookupError

§

const NAME: &'static str = "PyProcessLookupError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyRecursionError

§

const NAME: &'static str = "PyRecursionError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyReferenceError

§

const NAME: &'static str = "PyReferenceError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyResourceWarning

§

const NAME: &'static str = "PyResourceWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyRuntimeError

§

const NAME: &'static str = "PyRuntimeError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyRuntimeWarning

§

const NAME: &'static str = "PyRuntimeWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyStopAsyncIteration

§

const NAME: &'static str = "PyStopAsyncIteration"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyStopIteration

§

const NAME: &'static str = "PyStopIteration"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PySyntaxError

§

const NAME: &'static str = "PySyntaxError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PySyntaxWarning

§

const NAME: &'static str = "PySyntaxWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PySystemError

§

const NAME: &'static str = "PySystemError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PySystemExit

§

const NAME: &'static str = "PySystemExit"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyTimeoutError

§

const NAME: &'static str = "PyTimeoutError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyTypeError

§

const NAME: &'static str = "PyTypeError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyUnboundLocalError

§

const NAME: &'static str = "PyUnboundLocalError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyUnicodeDecodeError

§

const NAME: &'static str = "PyUnicodeDecodeError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyUnicodeEncodeError

§

const NAME: &'static str = "PyUnicodeEncodeError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyUnicodeError

§

const NAME: &'static str = "PyUnicodeError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyUnicodeTranslateError

§

const NAME: &'static str = "PyUnicodeTranslateError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyUnicodeWarning

§

const NAME: &'static str = "PyUnicodeWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyUserWarning

§

const NAME: &'static str = "PyUserWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyValueError

§

const NAME: &'static str = "PyValueError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyWarning

§

const NAME: &'static str = "PyWarning"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyZeroDivisionError

§

const NAME: &'static str = "PyZeroDivisionError"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PanicException

§

const NAME: &'static str = "PanicException"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyAny

§

const NAME: &'static str = "PyAny"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyBool

§

const NAME: &'static str = "PyBool"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyByteArray

§

const NAME: &'static str = "PyByteArray"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyBytes

§

const NAME: &'static str = "PyBytes"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyCFunction

§

const NAME: &'static str = "PyCFunction"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyCapsule

§

const NAME: &'static str = "PyCapsule"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyCode

§

const NAME: &'static str = "PyCode"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyComplex

§

const NAME: &'static str = "PyComplex"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDate

§

const NAME: &'static str = "PyDate"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDateTime

§

const NAME: &'static str = "PyDateTime"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDelta

§

const NAME: &'static str = "PyDelta"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDict

§

const NAME: &'static str = "PyDict"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDictItems

§

const NAME: &'static str = "PyDictItems"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDictKeys

§

const NAME: &'static str = "PyDictKeys"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyDictValues

§

const NAME: &'static str = "PyDictValues"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyEllipsis

§

const NAME: &'static str = "ellipsis"

§

const MODULE: Option<&'static str> = None

§

impl PyTypeInfo for PyFloat

§

const NAME: &'static str = "PyFloat"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyFrame

§

const NAME: &'static str = "PyFrame"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyFrozenSet

§

const NAME: &'static str = "PyFrozenSet"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyFunction

§

const NAME: &'static str = "PyFunction"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyInt

§

const NAME: &'static str = "PyInt"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyList

§

const NAME: &'static str = "PyList"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyMappingProxy

§

const NAME: &'static str = "PyMappingProxy"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyMemoryView

§

const NAME: &'static str = "PyMemoryView"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyModule

§

const NAME: &'static str = "PyModule"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyNone

§

const NAME: &'static str = "NoneType"

§

const MODULE: Option<&'static str> = None

§

impl PyTypeInfo for PyNotImplemented

§

const NAME: &'static str = "NotImplementedType"

§

const MODULE: Option<&'static str> = None

§

impl PyTypeInfo for PySet

§

const NAME: &'static str = "PySet"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PySlice

§

const NAME: &'static str = "PySlice"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyString

§

const NAME: &'static str = "PyString"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PySuper

§

const NAME: &'static str = "PySuper"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyTime

§

const NAME: &'static str = "PyTime"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyTraceback

§

const NAME: &'static str = "PyTraceback"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyTuple

§

const NAME: &'static str = "PyTuple"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyType

§

const NAME: &'static str = "PyType"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyTzInfo

§

const NAME: &'static str = "PyTzInfo"

§

const MODULE: Option<&'static str>

§

impl PyTypeInfo for PyWeakrefReference

§

const NAME: &'static str = "PyWeakrefReference"

§

const MODULE: Option<&'static str>