[][src]Trait pyo3::type_object::PyTypeInfo

pub unsafe trait PyTypeInfo: Sized {
    type Type;
    type BaseType: PyTypeInfo + PyTypeObject;
    type Layout: PyLayout<Self>;
    type BaseLayout: PySizedLayout<Self::BaseType>;
    type Initializer: PyObjectInit<Self>;
    type AsRefTarget: PyNativeType;

    pub const NAME: &'static str;
    pub const MODULE: Option<&'static str>;
    pub const DESCRIPTION: &'static str;
    pub const FLAGS: usize;

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

    pub fn is_type_of(object: &PyAny) -> bool { ... }
pub fn is_exact_type_of(object: &PyAny) -> bool { ... } }

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

Associated Types

type Type[src]

Type of objects to store in PyObject struct

type BaseType: PyTypeInfo + PyTypeObject[src]

Base class

type Layout: PyLayout<Self>[src]

Layout

type BaseLayout: PySizedLayout<Self::BaseType>[src]

Layout of Basetype.

type Initializer: PyObjectInit<Self>[src]

Initializer for layout

type AsRefTarget: PyNativeType[src]

Utility type to make Py::as_ref work

Loading content...

Associated Constants

pub const NAME: &'static str[src]

Class name

pub const MODULE: Option<&'static str>[src]

Module name, if any

pub const DESCRIPTION: &'static str[src]

Class doc string

pub const FLAGS: usize[src]

Type flags (ie PY_TYPE_FLAG_GC, PY_TYPE_FLAG_WEAKREF)

Loading content...

Required methods

pub fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject[src]

PyTypeObject instance for this type.

Loading content...

Provided methods

pub fn is_type_of(object: &PyAny) -> bool[src]

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

pub fn is_exact_type_of(object: &PyAny) -> bool[src]

Checks if object is an instance of this type.

Loading content...

Implementors

impl PyTypeInfo for CancelledError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for IncompleteReadError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for InvalidStateError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for LimitOverrunError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for QueueEmpty[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for QueueFull[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for TimeoutError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for gaierror[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for herror[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for timeout[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyArithmeticError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyAssertionError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyAttributeError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyBaseException[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyBlockingIOError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyBrokenPipeError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyBufferError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyChildProcessError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyConnectionAbortedError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyConnectionError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyConnectionRefusedError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyConnectionResetError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyEOFError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyEnvironmentError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyException[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyFileExistsError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyFileNotFoundError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyFloatingPointError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyGeneratorExit[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyIOError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyImportError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyIndexError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyInterruptedError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyIsADirectoryError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyKeyError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyKeyboardInterrupt[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyLookupError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyMemoryError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyModuleNotFoundError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyNameError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyNotADirectoryError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyNotImplementedError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyOSError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyOSErrorObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyOverflowError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyPermissionError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyProcessLookupError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyRecursionError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyReferenceError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyRuntimeError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyStopAsyncIteration[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyStopIteration[src]

type Type = ()

type BaseType = PyAny

type Layout = PyStopIterationObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PySyntaxError[src]

type Type = ()

type BaseType = PyAny

type Layout = PySyntaxErrorObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PySystemError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PySystemExit[src]

type Type = ()

type BaseType = PyAny

type Layout = PySystemExitObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyTimeoutError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyTypeError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyUnboundLocalError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyUnicodeDecodeError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyUnicodeEncodeError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyUnicodeError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyUnicodeErrorObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyUnicodeTranslateError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyValueError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyZeroDivisionError[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PanicException[src]

type Type = ()

type BaseType = PyAny

type Layout = PyBaseExceptionObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyAny[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyModule[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyBool[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyByteArray[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyBytes[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyCFunction[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyComplex[src]

type Type = ()

type BaseType = PyAny

type Layout = PyComplexObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyDate[src]

type Type = ()

type BaseType = PyAny

type Layout = PyDateTime_Date

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyDateTime[src]

type Type = ()

type BaseType = PyAny

type Layout = PyDateTime_DateTime

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyDelta[src]

type Type = ()

type BaseType = PyAny

type Layout = PyDateTime_Delta

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyDict[src]

type Type = ()

type BaseType = PyAny

type Layout = PyDictObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyFloat[src]

type Type = ()

type BaseType = PyAny

type Layout = PyFloatObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyFrozenSet[src]

type Type = ()

type BaseType = PyAny

type Layout = PySetObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyFunction[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyList[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyLong[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PySet[src]

type Type = ()

type BaseType = PyAny

type Layout = PySetObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PySlice[src]

type Type = ()

type BaseType = PyAny

type Layout = PySliceObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyString[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyTime[src]

type Type = ()

type BaseType = PyAny

type Layout = PyDateTime_Time

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyTuple[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyType[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

impl PyTypeInfo for PyTzInfo[src]

type Type = ()

type BaseType = PyAny

type Layout = PyObject

type BaseLayout = PyObject

type Initializer = PyNativeTypeInitializer<Self>

type AsRefTarget = Self

Loading content...