Trait pyo3::instance::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§
sourcetype AsRefSource: HasPyGilRef<AsRefTarget = Self>
type AsRefSource: HasPyGilRef<AsRefTarget = Self>
The form of this which is stored inside a Py<T>
smart pointer.
Provided Methods§
sourcefn as_borrowed(&self) -> Borrowed<'_, '_, Self::AsRefSource>
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.
sourceunsafe fn unchecked_downcast(obj: &PyAny) -> &Self
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§
Implementors§
source§impl PyNativeType for CancelledError
impl PyNativeType for CancelledError
type AsRefSource = CancelledError
source§impl PyNativeType for IncompleteReadError
impl PyNativeType for IncompleteReadError
type AsRefSource = IncompleteReadError
source§impl PyNativeType for InvalidStateError
impl PyNativeType for InvalidStateError
type AsRefSource = InvalidStateError
source§impl PyNativeType for LimitOverrunError
impl PyNativeType for LimitOverrunError
type AsRefSource = LimitOverrunError
source§impl PyNativeType for QueueEmpty
impl PyNativeType for QueueEmpty
type AsRefSource = QueueEmpty
source§impl PyNativeType for QueueFull
impl PyNativeType for QueueFull
type AsRefSource = QueueFull
source§impl PyNativeType for TimeoutError
impl PyNativeType for TimeoutError
type AsRefSource = TimeoutError
source§impl PyNativeType for gaierror
impl PyNativeType for gaierror
type AsRefSource = gaierror
source§impl PyNativeType for herror
impl PyNativeType for herror
type AsRefSource = herror
source§impl PyNativeType for timeout
impl PyNativeType for timeout
type AsRefSource = timeout
source§impl PyNativeType for PyArithmeticError
impl PyNativeType for PyArithmeticError
type AsRefSource = PyArithmeticError
source§impl PyNativeType for PyAssertionError
impl PyNativeType for PyAssertionError
type AsRefSource = PyAssertionError
source§impl PyNativeType for PyAttributeError
impl PyNativeType for PyAttributeError
type AsRefSource = PyAttributeError
source§impl PyNativeType for PyBaseException
impl PyNativeType for PyBaseException
type AsRefSource = PyBaseException
source§impl PyNativeType for PyBlockingIOError
impl PyNativeType for PyBlockingIOError
type AsRefSource = PyBlockingIOError
source§impl PyNativeType for PyBrokenPipeError
impl PyNativeType for PyBrokenPipeError
type AsRefSource = PyBrokenPipeError
source§impl PyNativeType for PyBufferError
impl PyNativeType for PyBufferError
type AsRefSource = PyBufferError
source§impl PyNativeType for PyBytesWarning
impl PyNativeType for PyBytesWarning
type AsRefSource = PyBytesWarning
source§impl PyNativeType for PyChildProcessError
impl PyNativeType for PyChildProcessError
type AsRefSource = PyChildProcessError
source§impl PyNativeType for PyConnectionError
impl PyNativeType for PyConnectionError
type AsRefSource = PyConnectionError
source§impl PyNativeType for PyDeprecationWarning
impl PyNativeType for PyDeprecationWarning
type AsRefSource = PyDeprecationWarning
source§impl PyNativeType for PyEOFError
impl PyNativeType for PyEOFError
type AsRefSource = PyEOFError
source§impl PyNativeType for PyEnvironmentError
impl PyNativeType for PyEnvironmentError
type AsRefSource = PyEnvironmentError
source§impl PyNativeType for PyException
impl PyNativeType for PyException
type AsRefSource = PyException
source§impl PyNativeType for PyFileExistsError
impl PyNativeType for PyFileExistsError
type AsRefSource = PyFileExistsError
source§impl PyNativeType for PyFileNotFoundError
impl PyNativeType for PyFileNotFoundError
type AsRefSource = PyFileNotFoundError
source§impl PyNativeType for PyFloatingPointError
impl PyNativeType for PyFloatingPointError
type AsRefSource = PyFloatingPointError
source§impl PyNativeType for PyFutureWarning
impl PyNativeType for PyFutureWarning
type AsRefSource = PyFutureWarning
source§impl PyNativeType for PyGeneratorExit
impl PyNativeType for PyGeneratorExit
type AsRefSource = PyGeneratorExit
source§impl PyNativeType for PyIOError
impl PyNativeType for PyIOError
type AsRefSource = PyIOError
source§impl PyNativeType for PyImportError
impl PyNativeType for PyImportError
type AsRefSource = PyImportError
source§impl PyNativeType for PyImportWarning
impl PyNativeType for PyImportWarning
type AsRefSource = PyImportWarning
source§impl PyNativeType for PyIndexError
impl PyNativeType for PyIndexError
type AsRefSource = PyIndexError
source§impl PyNativeType for PyInterruptedError
impl PyNativeType for PyInterruptedError
type AsRefSource = PyInterruptedError
source§impl PyNativeType for PyIsADirectoryError
impl PyNativeType for PyIsADirectoryError
type AsRefSource = PyIsADirectoryError
source§impl PyNativeType for PyKeyError
impl PyNativeType for PyKeyError
type AsRefSource = PyKeyError
source§impl PyNativeType for PyKeyboardInterrupt
impl PyNativeType for PyKeyboardInterrupt
type AsRefSource = PyKeyboardInterrupt
source§impl PyNativeType for PyLookupError
impl PyNativeType for PyLookupError
type AsRefSource = PyLookupError
source§impl PyNativeType for PyMemoryError
impl PyNativeType for PyMemoryError
type AsRefSource = PyMemoryError
source§impl PyNativeType for PyNameError
impl PyNativeType for PyNameError
type AsRefSource = PyNameError
source§impl PyNativeType for PyNotADirectoryError
impl PyNativeType for PyNotADirectoryError
type AsRefSource = PyNotADirectoryError
source§impl PyNativeType for PyOSError
impl PyNativeType for PyOSError
type AsRefSource = PyOSError
source§impl PyNativeType for PyOverflowError
impl PyNativeType for PyOverflowError
type AsRefSource = PyOverflowError
source§impl PyNativeType for PyPermissionError
impl PyNativeType for PyPermissionError
type AsRefSource = PyPermissionError
source§impl PyNativeType for PyProcessLookupError
impl PyNativeType for PyProcessLookupError
type AsRefSource = PyProcessLookupError
source§impl PyNativeType for PyRecursionError
impl PyNativeType for PyRecursionError
type AsRefSource = PyRecursionError
source§impl PyNativeType for PyReferenceError
impl PyNativeType for PyReferenceError
type AsRefSource = PyReferenceError
source§impl PyNativeType for PyResourceWarning
impl PyNativeType for PyResourceWarning
type AsRefSource = PyResourceWarning
source§impl PyNativeType for PyRuntimeError
impl PyNativeType for PyRuntimeError
type AsRefSource = PyRuntimeError
source§impl PyNativeType for PyRuntimeWarning
impl PyNativeType for PyRuntimeWarning
type AsRefSource = PyRuntimeWarning
source§impl PyNativeType for PyStopAsyncIteration
impl PyNativeType for PyStopAsyncIteration
type AsRefSource = PyStopAsyncIteration
source§impl PyNativeType for PyStopIteration
impl PyNativeType for PyStopIteration
type AsRefSource = PyStopIteration
source§impl PyNativeType for PySyntaxError
impl PyNativeType for PySyntaxError
type AsRefSource = PySyntaxError
source§impl PyNativeType for PySyntaxWarning
impl PyNativeType for PySyntaxWarning
type AsRefSource = PySyntaxWarning
source§impl PyNativeType for PySystemError
impl PyNativeType for PySystemError
type AsRefSource = PySystemError
source§impl PyNativeType for PySystemExit
impl PyNativeType for PySystemExit
type AsRefSource = PySystemExit
source§impl PyNativeType for PyTimeoutError
impl PyNativeType for PyTimeoutError
type AsRefSource = PyTimeoutError
source§impl PyNativeType for PyTypeError
impl PyNativeType for PyTypeError
type AsRefSource = PyTypeError
source§impl PyNativeType for PyUnboundLocalError
impl PyNativeType for PyUnboundLocalError
type AsRefSource = PyUnboundLocalError
source§impl PyNativeType for PyUnicodeDecodeError
impl PyNativeType for PyUnicodeDecodeError
type AsRefSource = PyUnicodeDecodeError
source§impl PyNativeType for PyUnicodeEncodeError
impl PyNativeType for PyUnicodeEncodeError
type AsRefSource = PyUnicodeEncodeError
source§impl PyNativeType for PyUnicodeError
impl PyNativeType for PyUnicodeError
type AsRefSource = PyUnicodeError
source§impl PyNativeType for PyUnicodeWarning
impl PyNativeType for PyUnicodeWarning
type AsRefSource = PyUnicodeWarning
source§impl PyNativeType for PyUserWarning
impl PyNativeType for PyUserWarning
type AsRefSource = PyUserWarning
source§impl PyNativeType for PyValueError
impl PyNativeType for PyValueError
type AsRefSource = PyValueError
source§impl PyNativeType for PyWarning
impl PyNativeType for PyWarning
type AsRefSource = PyWarning
source§impl PyNativeType for PyZeroDivisionError
impl PyNativeType for PyZeroDivisionError
type AsRefSource = PyZeroDivisionError
source§impl PyNativeType for PanicException
impl PyNativeType for PanicException
type AsRefSource = PanicException
source§impl PyNativeType for PyAny
impl PyNativeType for PyAny
type AsRefSource = PyAny
source§impl PyNativeType for PyBool
impl PyNativeType for PyBool
type AsRefSource = PyBool
source§impl PyNativeType for PyByteArray
impl PyNativeType for PyByteArray
type AsRefSource = PyByteArray
source§impl PyNativeType for PyBytes
impl PyNativeType for PyBytes
type AsRefSource = PyBytes
source§impl PyNativeType for PyCapsule
impl PyNativeType for PyCapsule
type AsRefSource = PyCapsule
source§impl PyNativeType for PyCode
Available on non-Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.
impl PyNativeType for PyCode
Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.type AsRefSource = PyCode
source§impl PyNativeType for PyComplex
impl PyNativeType for PyComplex
type AsRefSource = PyComplex
source§impl PyNativeType for PyDate
Available on non-Py_LIMITED_API
only.
impl PyNativeType for PyDate
Py_LIMITED_API
only.type AsRefSource = PyDate
source§impl PyNativeType for PyDateTime
Available on non-Py_LIMITED_API
only.
impl PyNativeType for PyDateTime
Py_LIMITED_API
only.type AsRefSource = PyDateTime
source§impl PyNativeType for PyDelta
Available on non-Py_LIMITED_API
only.
impl PyNativeType for PyDelta
Py_LIMITED_API
only.type AsRefSource = PyDelta
source§impl PyNativeType for PyTime
Available on non-Py_LIMITED_API
only.
impl PyNativeType for PyTime
Py_LIMITED_API
only.type AsRefSource = PyTime
source§impl PyNativeType for PyTzInfo
Available on non-Py_LIMITED_API
only.
impl PyNativeType for PyTzInfo
Py_LIMITED_API
only.type AsRefSource = PyTzInfo
source§impl PyNativeType for PyDict
impl PyNativeType for PyDict
type AsRefSource = PyDict
source§impl PyNativeType for PyDictItems
impl PyNativeType for PyDictItems
type AsRefSource = PyDictItems
source§impl PyNativeType for PyDictKeys
impl PyNativeType for PyDictKeys
type AsRefSource = PyDictKeys
source§impl PyNativeType for PyDictValues
impl PyNativeType for PyDictValues
type AsRefSource = PyDictValues
source§impl PyNativeType for PyEllipsis
impl PyNativeType for PyEllipsis
type AsRefSource = PyEllipsis
source§impl PyNativeType for PyFloat
impl PyNativeType for PyFloat
type AsRefSource = PyFloat
source§impl PyNativeType for PyFrame
Available on non-Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.
impl PyNativeType for PyFrame
Py_LIMITED_API
and non-PyPy
and non-GraalPy
only.type AsRefSource = PyFrame
source§impl PyNativeType for PyFrozenSet
impl PyNativeType for PyFrozenSet
type AsRefSource = PyFrozenSet
source§impl PyNativeType for PyCFunction
impl PyNativeType for PyCFunction
type AsRefSource = PyCFunction
source§impl PyNativeType for PyFunction
impl PyNativeType for PyFunction
type AsRefSource = PyFunction
source§impl PyNativeType for PyIterator
impl PyNativeType for PyIterator
type AsRefSource = PyIterator
source§impl PyNativeType for PyList
impl PyNativeType for PyList
type AsRefSource = PyList
source§impl PyNativeType for PyMapping
impl PyNativeType for PyMapping
type AsRefSource = PyMapping
source§impl PyNativeType for PyMemoryView
impl PyNativeType for PyMemoryView
type AsRefSource = PyMemoryView
source§impl PyNativeType for PyModule
impl PyNativeType for PyModule
type AsRefSource = PyModule
source§impl PyNativeType for PyNone
impl PyNativeType for PyNone
type AsRefSource = PyNone
source§impl PyNativeType for PyNotImplemented
impl PyNativeType for PyNotImplemented
type AsRefSource = PyNotImplemented
source§impl PyNativeType for PyLong
impl PyNativeType for PyLong
type AsRefSource = PyLong
source§impl PyNativeType for PySuper
Available on neither PyPy
nor GraalPy
.
impl PyNativeType for PySuper
PyPy
nor GraalPy
.