pub struct PyType(/* private fields */);
Expand description
Represents a reference to a Python type object.
Implementations§
source§impl 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§
source§impl<'s> FromPyObject<'s> for &'s PyType
impl<'s> FromPyObject<'s> for &'s PyType
source§impl<'s> FromPyObject<'s> for PyType
impl<'s> FromPyObject<'s> for PyType
source§impl PythonObject for PyType
impl PythonObject for PyType
source§unsafe 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.
source§unsafe 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.
source§fn into_object(self) -> PyObject
fn into_object(self) -> PyObject
Casts the Python object to PyObject.
source§impl PythonObjectWithCheckedDowncast for PyType
impl PythonObjectWithCheckedDowncast for PyType
source§fn 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.
source§fn 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.
source§impl PythonObjectWithTypeObject for PyType
impl PythonObjectWithTypeObject for PyType
source§fn type_object(py: Python<'_>) -> PyType
fn type_object(py: Python<'_>) -> PyType
Retrieves the type object for this Python object type.
source§impl ToPyObject for PyType
impl ToPyObject for PyType
Identity conversion: allows using existing PyObject
instances where
T: ToPyObject
is expected.
type ObjectType = PyType
source§fn to_py_object(&self, py: Python<'_>) -> PyType
fn to_py_object(&self, py: Python<'_>) -> PyType
Converts self into a Python object.
impl Eq for PyType
Auto Trait Implementations§
impl Freeze for PyType
impl RefUnwindSafe for PyType
impl Send for PyType
impl Sync for PyType
impl Unpin for PyType
impl UnwindSafe for PyType
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more