Trait pyo3::type_object::PyTypeInfo

source ·
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_bound(py: Python<'_>) -> Bound<'_, PyType> { ... }
    fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool { ... }
    fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool { ... }
}
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§

source

const NAME: &'static str

Class name.

source

const MODULE: Option<&'static str>

Module name, if any.

Required Methods§

source

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

Returns the PyTypeObject instance for this type.

Provided Methods§

source

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

Returns the safe abstraction over the type object.

source

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

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

source

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

Checks if object is an instance of this type.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl PyTypeInfo for Coroutine

source§

const NAME: &'static str = "Coroutine"

source§

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

source§

impl PyTypeInfo for CancelledError

source§

const NAME: &'static str = "CancelledError"

source§

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

source§

impl PyTypeInfo for IncompleteReadError

source§

const NAME: &'static str = "IncompleteReadError"

source§

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

source§

impl PyTypeInfo for InvalidStateError

source§

const NAME: &'static str = "InvalidStateError"

source§

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

source§

impl PyTypeInfo for LimitOverrunError

source§

const NAME: &'static str = "LimitOverrunError"

source§

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

source§

impl PyTypeInfo for QueueEmpty

source§

const NAME: &'static str = "QueueEmpty"

source§

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

source§

impl PyTypeInfo for QueueFull

source§

const NAME: &'static str = "QueueFull"

source§

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

source§

impl PyTypeInfo for TimeoutError

source§

const NAME: &'static str = "TimeoutError"

source§

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

source§

impl PyTypeInfo for gaierror

source§

const NAME: &'static str = "gaierror"

source§

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

source§

impl PyTypeInfo for herror

source§

const NAME: &'static str = "herror"

source§

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

source§

impl PyTypeInfo for timeout

source§

const NAME: &'static str = "timeout"

source§

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

source§

impl PyTypeInfo for PyArithmeticError

source§

const NAME: &'static str = "PyArithmeticError"

source§

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

source§

impl PyTypeInfo for PyAssertionError

source§

const NAME: &'static str = "PyAssertionError"

source§

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

source§

impl PyTypeInfo for PyAttributeError

source§

const NAME: &'static str = "PyAttributeError"

source§

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

source§

impl PyTypeInfo for PyBaseException

source§

const NAME: &'static str = "PyBaseException"

source§

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

source§

impl PyTypeInfo for PyBlockingIOError

source§

const NAME: &'static str = "PyBlockingIOError"

source§

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

source§

impl PyTypeInfo for PyBrokenPipeError

source§

const NAME: &'static str = "PyBrokenPipeError"

source§

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

source§

impl PyTypeInfo for PyBufferError

source§

const NAME: &'static str = "PyBufferError"

source§

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

source§

impl PyTypeInfo for PyBytesWarning

source§

const NAME: &'static str = "PyBytesWarning"

source§

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

source§

impl PyTypeInfo for PyChildProcessError

source§

const NAME: &'static str = "PyChildProcessError"

source§

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

source§

impl PyTypeInfo for PyConnectionAbortedError

source§

const NAME: &'static str = "PyConnectionAbortedError"

source§

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

source§

impl PyTypeInfo for PyConnectionError

source§

const NAME: &'static str = "PyConnectionError"

source§

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

source§

impl PyTypeInfo for PyConnectionRefusedError

source§

const NAME: &'static str = "PyConnectionRefusedError"

source§

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

source§

impl PyTypeInfo for PyConnectionResetError

source§

const NAME: &'static str = "PyConnectionResetError"

source§

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

source§

impl PyTypeInfo for PyDeprecationWarning

source§

const NAME: &'static str = "PyDeprecationWarning"

source§

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

source§

impl PyTypeInfo for PyEOFError

source§

const NAME: &'static str = "PyEOFError"

source§

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

source§

impl PyTypeInfo for PyEnvironmentError

source§

const NAME: &'static str = "PyEnvironmentError"

source§

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

source§

impl PyTypeInfo for PyException

source§

const NAME: &'static str = "PyException"

source§

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

source§

impl PyTypeInfo for PyFileExistsError

source§

const NAME: &'static str = "PyFileExistsError"

source§

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

source§

impl PyTypeInfo for PyFileNotFoundError

source§

const NAME: &'static str = "PyFileNotFoundError"

source§

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

source§

impl PyTypeInfo for PyFloatingPointError

source§

const NAME: &'static str = "PyFloatingPointError"

source§

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

source§

impl PyTypeInfo for PyFutureWarning

source§

const NAME: &'static str = "PyFutureWarning"

source§

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

source§

impl PyTypeInfo for PyGeneratorExit

source§

const NAME: &'static str = "PyGeneratorExit"

source§

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

source§

impl PyTypeInfo for PyIOError

source§

const NAME: &'static str = "PyIOError"

source§

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

source§

impl PyTypeInfo for PyImportError

source§

const NAME: &'static str = "PyImportError"

source§

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

source§

impl PyTypeInfo for PyImportWarning

source§

const NAME: &'static str = "PyImportWarning"

source§

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

source§

impl PyTypeInfo for PyIndexError

source§

const NAME: &'static str = "PyIndexError"

source§

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

source§

impl PyTypeInfo for PyInterruptedError

source§

const NAME: &'static str = "PyInterruptedError"

source§

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

source§

impl PyTypeInfo for PyIsADirectoryError

source§

const NAME: &'static str = "PyIsADirectoryError"

source§

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

source§

impl PyTypeInfo for PyKeyError

source§

const NAME: &'static str = "PyKeyError"

source§

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

source§

impl PyTypeInfo for PyKeyboardInterrupt

source§

const NAME: &'static str = "PyKeyboardInterrupt"

source§

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

source§

impl PyTypeInfo for PyLookupError

source§

const NAME: &'static str = "PyLookupError"

source§

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

source§

impl PyTypeInfo for PyMemoryError

source§

const NAME: &'static str = "PyMemoryError"

source§

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

source§

impl PyTypeInfo for PyModuleNotFoundError

source§

const NAME: &'static str = "PyModuleNotFoundError"

source§

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

source§

impl PyTypeInfo for PyNameError

source§

const NAME: &'static str = "PyNameError"

source§

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

source§

impl PyTypeInfo for PyNotADirectoryError

source§

const NAME: &'static str = "PyNotADirectoryError"

source§

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

source§

impl PyTypeInfo for PyNotImplementedError

source§

const NAME: &'static str = "PyNotImplementedError"

source§

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

source§

impl PyTypeInfo for PyOSError

source§

const NAME: &'static str = "PyOSError"

source§

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

source§

impl PyTypeInfo for PyOverflowError

source§

const NAME: &'static str = "PyOverflowError"

source§

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

source§

impl PyTypeInfo for PyPendingDeprecationWarning

source§

const NAME: &'static str = "PyPendingDeprecationWarning"

source§

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

source§

impl PyTypeInfo for PyPermissionError

source§

const NAME: &'static str = "PyPermissionError"

source§

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

source§

impl PyTypeInfo for PyProcessLookupError

source§

const NAME: &'static str = "PyProcessLookupError"

source§

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

source§

impl PyTypeInfo for PyRecursionError

source§

const NAME: &'static str = "PyRecursionError"

source§

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

source§

impl PyTypeInfo for PyReferenceError

source§

const NAME: &'static str = "PyReferenceError"

source§

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

source§

impl PyTypeInfo for PyResourceWarning

source§

const NAME: &'static str = "PyResourceWarning"

source§

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

source§

impl PyTypeInfo for PyRuntimeError

source§

const NAME: &'static str = "PyRuntimeError"

source§

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

source§

impl PyTypeInfo for PyRuntimeWarning

source§

const NAME: &'static str = "PyRuntimeWarning"

source§

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

source§

impl PyTypeInfo for PyStopAsyncIteration

source§

const NAME: &'static str = "PyStopAsyncIteration"

source§

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

source§

impl PyTypeInfo for PyStopIteration

source§

const NAME: &'static str = "PyStopIteration"

source§

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

source§

impl PyTypeInfo for PySyntaxError

source§

const NAME: &'static str = "PySyntaxError"

source§

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

source§

impl PyTypeInfo for PySyntaxWarning

source§

const NAME: &'static str = "PySyntaxWarning"

source§

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

source§

impl PyTypeInfo for PySystemError

source§

const NAME: &'static str = "PySystemError"

source§

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

source§

impl PyTypeInfo for PySystemExit

source§

const NAME: &'static str = "PySystemExit"

source§

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

source§

impl PyTypeInfo for PyTimeoutError

source§

const NAME: &'static str = "PyTimeoutError"

source§

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

source§

impl PyTypeInfo for PyTypeError

source§

const NAME: &'static str = "PyTypeError"

source§

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

source§

impl PyTypeInfo for PyUnboundLocalError

source§

const NAME: &'static str = "PyUnboundLocalError"

source§

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

source§

impl PyTypeInfo for PyUnicodeDecodeError

source§

const NAME: &'static str = "PyUnicodeDecodeError"

source§

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

source§

impl PyTypeInfo for PyUnicodeEncodeError

source§

const NAME: &'static str = "PyUnicodeEncodeError"

source§

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

source§

impl PyTypeInfo for PyUnicodeError

source§

const NAME: &'static str = "PyUnicodeError"

source§

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

source§

impl PyTypeInfo for PyUnicodeTranslateError

source§

const NAME: &'static str = "PyUnicodeTranslateError"

source§

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

source§

impl PyTypeInfo for PyUnicodeWarning

source§

const NAME: &'static str = "PyUnicodeWarning"

source§

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

source§

impl PyTypeInfo for PyUserWarning

source§

const NAME: &'static str = "PyUserWarning"

source§

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

source§

impl PyTypeInfo for PyValueError

source§

const NAME: &'static str = "PyValueError"

source§

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

source§

impl PyTypeInfo for PyWarning

source§

const NAME: &'static str = "PyWarning"

source§

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

source§

impl PyTypeInfo for PyZeroDivisionError

source§

const NAME: &'static str = "PyZeroDivisionError"

source§

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

source§

impl PyTypeInfo for PanicException

source§

const NAME: &'static str = "PanicException"

source§

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

source§

impl PyTypeInfo for PyAny

source§

const NAME: &'static str = "PyAny"

source§

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

source§

impl PyTypeInfo for PyBool

source§

const NAME: &'static str = "PyBool"

source§

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

source§

impl PyTypeInfo for PyByteArray

source§

const NAME: &'static str = "PyByteArray"

source§

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

source§

impl PyTypeInfo for PyBytes

source§

const NAME: &'static str = "PyBytes"

source§

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

source§

impl PyTypeInfo for PyCFunction

source§

const NAME: &'static str = "PyCFunction"

source§

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

source§

impl PyTypeInfo for PyCapsule

source§

const NAME: &'static str = "PyCapsule"

source§

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

source§

impl PyTypeInfo for PyCode

source§

const NAME: &'static str = "PyCode"

source§

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

source§

impl PyTypeInfo for PyComplex

source§

const NAME: &'static str = "PyComplex"

source§

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

source§

impl PyTypeInfo for PyDate

source§

const NAME: &'static str = "PyDate"

source§

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

source§

impl PyTypeInfo for PyDateTime

source§

const NAME: &'static str = "PyDateTime"

source§

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

source§

impl PyTypeInfo for PyDelta

source§

const NAME: &'static str = "PyDelta"

source§

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

source§

impl PyTypeInfo for PyDict

source§

const NAME: &'static str = "PyDict"

source§

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

source§

impl PyTypeInfo for PyDictItems

source§

const NAME: &'static str = "PyDictItems"

source§

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

source§

impl PyTypeInfo for PyDictKeys

source§

const NAME: &'static str = "PyDictKeys"

source§

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

source§

impl PyTypeInfo for PyDictValues

source§

const NAME: &'static str = "PyDictValues"

source§

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

source§

impl PyTypeInfo for PyEllipsis

source§

const NAME: &'static str = "ellipsis"

source§

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

source§

impl PyTypeInfo for PyFloat

source§

const NAME: &'static str = "PyFloat"

source§

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

source§

impl PyTypeInfo for PyFrame

source§

const NAME: &'static str = "PyFrame"

source§

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

source§

impl PyTypeInfo for PyFrozenSet

source§

const NAME: &'static str = "PyFrozenSet"

source§

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

source§

impl PyTypeInfo for PyFunction

source§

const NAME: &'static str = "PyFunction"

source§

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

source§

impl PyTypeInfo for PyList

source§

const NAME: &'static str = "PyList"

source§

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

source§

impl PyTypeInfo for PyLong

source§

const NAME: &'static str = "PyLong"

source§

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

source§

impl PyTypeInfo for PyMemoryView

source§

const NAME: &'static str = "PyMemoryView"

source§

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

source§

impl PyTypeInfo for PyModule

source§

const NAME: &'static str = "PyModule"

source§

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

source§

impl PyTypeInfo for PyNone

source§

const NAME: &'static str = "NoneType"

source§

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

source§

impl PyTypeInfo for PyNotImplemented

source§

const NAME: &'static str = "NotImplementedType"

source§

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

source§

impl PyTypeInfo for PySet

source§

const NAME: &'static str = "PySet"

source§

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

source§

impl PyTypeInfo for PySlice

source§

const NAME: &'static str = "PySlice"

source§

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

source§

impl PyTypeInfo for PyString

source§

const NAME: &'static str = "PyString"

source§

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

source§

impl PyTypeInfo for PySuper

source§

const NAME: &'static str = "PySuper"

source§

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

source§

impl PyTypeInfo for PyTime

source§

const NAME: &'static str = "PyTime"

source§

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

source§

impl PyTypeInfo for PyTraceback

source§

const NAME: &'static str = "PyTraceback"

source§

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

source§

impl PyTypeInfo for PyTuple

source§

const NAME: &'static str = "PyTuple"

source§

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

source§

impl PyTypeInfo for PyType

source§

const NAME: &'static str = "PyType"

source§

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

source§

impl PyTypeInfo for PyTzInfo

source§

const NAME: &'static str = "PyTzInfo"

source§

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