pub struct PyType(_);
Expand description
Represents a reference to a Python type object.
Implementations
sourceimpl PyType
impl PyType
sourcepub fn as_type_ptr(&self) -> *mut PyTypeObject
pub fn as_type_ptr(&self) -> *mut PyTypeObject
Retrieves the underlying FFI pointer associated with this Python object.
sourcepub unsafe fn from_type_ptr(py: Python<'_>, p: *mut PyTypeObject) -> PyType
pub unsafe fn from_type_ptr(py: Python<'_>, p: *mut PyTypeObject) -> PyType
Retrieves the PyType instance for the given FFI pointer. This increments the reference count on the type object. Undefined behavior if the pointer is NULL or invalid.
sourcepub fn is_subtype_of(&self, _: Python<'_>, b: &PyType) -> bool
pub fn is_subtype_of(&self, _: Python<'_>, b: &PyType) -> bool
Return true if self
is a subtype of b
.
sourcepub fn is_instance(&self, _: Python<'_>, obj: &PyObject) -> bool
pub fn is_instance(&self, _: Python<'_>, obj: &PyObject) -> bool
Return true if obj
is an instance of self
.
Trait Implementations
sourceimpl<'s> FromPyObject<'s> for &'s PyType
impl<'s> FromPyObject<'s> for &'s PyType
sourceimpl<'s> FromPyObject<'s> for PyType
impl<'s> FromPyObject<'s> for PyType
sourceimpl PythonObject for PyType
impl PythonObject for PyType
sourceunsafe fn unchecked_downcast_from(obj: PyObject) -> Self
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
sourceunsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
sourcefn into_object(self) -> PyObject
fn into_object(self) -> PyObject
Casts the Python object to PyObject.
sourceimpl PythonObjectWithCheckedDowncast for PyType
impl PythonObjectWithCheckedDowncast for PyType
sourcefn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
sourcefn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyType, PythonObjectDowncastError<'p>>
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyType, PythonObjectDowncastError<'p>>
Cast from PyObject to a concrete Python object type.
sourceimpl PythonObjectWithTypeObject for PyType
impl PythonObjectWithTypeObject for PyType
sourcefn type_object(py: Python<'_>) -> PyType
fn type_object(py: Python<'_>) -> PyType
Retrieves the type object for this Python object type.
sourceimpl ToPyObject for PyType
impl ToPyObject for PyType
Identity conversion: allows using existing PyObject
instances where
T: ToPyObject
is expected.
type ObjectType = PyType
sourcefn to_py_object(&self, py: Python<'_>) -> PyType
fn to_py_object(&self, py: Python<'_>) -> PyType
Converts self into a Python object.
sourcefn into_py_object(self, _py: Python<'_>) -> PyType
fn into_py_object(self, _py: Python<'_>) -> PyType
Converts self into a Python object. Read more
impl Eq for PyType
Auto Trait Implementations
impl RefUnwindSafe for PyType
impl Send for PyType
impl Sync for PyType
impl Unpin for PyType
impl UnwindSafe for PyType
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more