Trait pyo3::PyNativeType

source ·
pub unsafe trait PyNativeType: Sized {
    type AsRefSource: HasPyGilRef<AsRefTarget = Self>;

    // Provided methods
    fn as_borrowed(&self) -> Borrowed<'_, '_, Self::AsRefSource> { ... }
    fn py(&self) -> Python<'_> { ... }
    unsafe fn unchecked_downcast(obj: &PyAny) -> &Self { ... }
}
Expand description

Types that are built into the Python interpreter.

PyO3 is designed in a way that all references to those types are bound to the GIL, which is why you can get a token from all references of those types.

§Safety

This trait must only be implemented for types which cannot be accessed without the GIL.

Required Associated Types§

source

type AsRefSource: HasPyGilRef<AsRefTarget = Self>

The form of this which is stored inside a Py<T> smart pointer.

Provided Methods§

source

fn as_borrowed(&self) -> Borrowed<'_, '_, Self::AsRefSource>

Cast &self to a Borrowed smart pointer.

Borrowed<T> implements Deref<Target=Bound<T>>, so can also be used in locations where Bound<T> is expected.

This is available as a migration tool to adjust code from the deprecated “GIL Refs” API to the Bound smart pointer API.

source

fn py(&self) -> Python<'_>

Returns a GIL marker constrained to the lifetime of this type.

source

unsafe fn unchecked_downcast(obj: &PyAny) -> &Self

Cast &PyAny to &Self without no type checking.

§Safety

obj must have the same layout as *const ffi::PyObject and must be an instance of a type corresponding to Self.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl PyNativeType for CancelledError

source§

impl PyNativeType for IncompleteReadError

source§

impl PyNativeType for InvalidStateError

source§

impl PyNativeType for LimitOverrunError

source§

impl PyNativeType for QueueEmpty

source§

impl PyNativeType for QueueFull

source§

impl PyNativeType for TimeoutError

source§

impl PyNativeType for gaierror

source§

impl PyNativeType for herror

source§

impl PyNativeType for timeout

source§

impl PyNativeType for PyArithmeticError

source§

impl PyNativeType for PyAssertionError

source§

impl PyNativeType for PyAttributeError

source§

impl PyNativeType for PyBaseException

source§

impl PyNativeType for PyBlockingIOError

source§

impl PyNativeType for PyBrokenPipeError

source§

impl PyNativeType for PyBufferError

source§

impl PyNativeType for PyBytesWarning

source§

impl PyNativeType for PyChildProcessError

source§

impl PyNativeType for PyConnectionAbortedError

source§

impl PyNativeType for PyConnectionError

source§

impl PyNativeType for PyConnectionRefusedError

source§

impl PyNativeType for PyConnectionResetError

source§

impl PyNativeType for PyDeprecationWarning

source§

impl PyNativeType for PyEOFError

source§

impl PyNativeType for PyEnvironmentError

source§

impl PyNativeType for PyException

source§

impl PyNativeType for PyFileExistsError

source§

impl PyNativeType for PyFileNotFoundError

source§

impl PyNativeType for PyFloatingPointError

source§

impl PyNativeType for PyFutureWarning

source§

impl PyNativeType for PyGeneratorExit

source§

impl PyNativeType for PyIOError

source§

impl PyNativeType for PyImportError

source§

impl PyNativeType for PyImportWarning

source§

impl PyNativeType for PyIndexError

source§

impl PyNativeType for PyInterruptedError

source§

impl PyNativeType for PyIsADirectoryError

source§

impl PyNativeType for PyKeyError

source§

impl PyNativeType for PyKeyboardInterrupt

source§

impl PyNativeType for PyLookupError

source§

impl PyNativeType for PyMemoryError

source§

impl PyNativeType for PyModuleNotFoundError

source§

impl PyNativeType for PyNameError

source§

impl PyNativeType for PyNotADirectoryError

source§

impl PyNativeType for PyNotImplementedError

source§

impl PyNativeType for PyOSError

source§

impl PyNativeType for PyOverflowError

source§

impl PyNativeType for PyPendingDeprecationWarning

source§

impl PyNativeType for PyPermissionError

source§

impl PyNativeType for PyProcessLookupError

source§

impl PyNativeType for PyRecursionError

source§

impl PyNativeType for PyReferenceError

source§

impl PyNativeType for PyResourceWarning

source§

impl PyNativeType for PyRuntimeError

source§

impl PyNativeType for PyRuntimeWarning

source§

impl PyNativeType for PyStopAsyncIteration

source§

impl PyNativeType for PyStopIteration

source§

impl PyNativeType for PySyntaxError

source§

impl PyNativeType for PySyntaxWarning

source§

impl PyNativeType for PySystemError

source§

impl PyNativeType for PySystemExit

source§

impl PyNativeType for PyTimeoutError

source§

impl PyNativeType for PyTypeError

source§

impl PyNativeType for PyUnboundLocalError

source§

impl PyNativeType for PyUnicodeDecodeError

source§

impl PyNativeType for PyUnicodeEncodeError

source§

impl PyNativeType for PyUnicodeError

source§

impl PyNativeType for PyUnicodeTranslateError

source§

impl PyNativeType for PyUnicodeWarning

source§

impl PyNativeType for PyUserWarning

source§

impl PyNativeType for PyValueError

source§

impl PyNativeType for PyWarning

source§

impl PyNativeType for PyZeroDivisionError

source§

impl PyNativeType for PanicException

source§

impl PyNativeType for PyAny

source§

impl PyNativeType for PyBool

source§

impl PyNativeType for PyByteArray

source§

impl PyNativeType for PyBytes

source§

impl PyNativeType for PyCFunction

source§

impl PyNativeType for PyCapsule

source§

impl PyNativeType for PyCode

source§

impl PyNativeType for PyComplex

source§

impl PyNativeType for PyDate

source§

impl PyNativeType for PyDateTime

source§

impl PyNativeType for PyDelta

source§

impl PyNativeType for PyDict

source§

impl PyNativeType for PyDictItems

source§

impl PyNativeType for PyDictKeys

source§

impl PyNativeType for PyDictValues

source§

impl PyNativeType for PyEllipsis

source§

impl PyNativeType for PyFloat

source§

impl PyNativeType for PyFrame

source§

impl PyNativeType for PyFrozenSet

source§

impl PyNativeType for PyFunction

source§

impl PyNativeType for PyIterator

source§

impl PyNativeType for PyList

source§

impl PyNativeType for PyLong

source§

impl PyNativeType for PyMapping

source§

impl PyNativeType for PyMemoryView

source§

impl PyNativeType for PyModule

source§

impl PyNativeType for PyNone

source§

impl PyNativeType for PyNotImplemented

source§

impl PyNativeType for PySequence

source§

impl PyNativeType for PySet

source§

impl PyNativeType for PySlice

source§

impl PyNativeType for PyString

source§

impl PyNativeType for PySuper

source§

impl PyNativeType for PyTime

source§

impl PyNativeType for PyTraceback

source§

impl PyNativeType for PyTuple

source§

impl PyNativeType for PyType

source§

impl PyNativeType for PyTzInfo

source§

impl<T: PyClass> PyNativeType for PyCell<T>

§

type AsRefSource = T