Trait pyo3::PyNativeType
source · pub unsafe trait PyNativeType: Sized {
// Provided methods
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.
Provided Methods§
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
.