Trait pyo3::prelude::PyTypeMethods
source · pub trait PyTypeMethods<'py>: Sealed {
// Required methods
fn as_type_ptr(&self) -> *mut PyTypeObject;
fn name(&self) -> PyResult<Cow<'_, str>>;
fn qualname(&self) -> PyResult<String>;
fn is_subclass(&self, other: &Bound<'_, PyAny>) -> PyResult<bool>;
fn is_subclass_of<T>(&self) -> PyResult<bool>
where T: PyTypeInfo;
}
Expand description
Implementation of functionality for PyType
.
These methods are defined for the Bound<'py, PyType>
smart pointer, so to use method call
syntax these methods are separated into a trait, because stable Rust does not yet support
arbitrary_self_types
.
Required Methods§
sourcefn as_type_ptr(&self) -> *mut PyTypeObject
fn as_type_ptr(&self) -> *mut PyTypeObject
Retrieves the underlying FFI pointer associated with this Python object.
sourcefn name(&self) -> PyResult<Cow<'_, str>>
fn name(&self) -> PyResult<Cow<'_, str>>
Gets the full name, which includes the module, of the PyType
.
sourcefn qualname(&self) -> PyResult<String>
fn qualname(&self) -> PyResult<String>
Gets the qualified name of the PyType
.
sourcefn is_subclass(&self, other: &Bound<'_, PyAny>) -> PyResult<bool>
fn is_subclass(&self, other: &Bound<'_, PyAny>) -> PyResult<bool>
Checks whether self
is a subclass of other
.
Equivalent to the Python expression issubclass(self, other)
.
sourcefn is_subclass_of<T>(&self) -> PyResult<bool>where
T: PyTypeInfo,
fn is_subclass_of<T>(&self) -> PyResult<bool>where
T: PyTypeInfo,
Checks whether self
is a subclass of type T
.
Equivalent to the Python expression issubclass(self, T)
, if the type
T
is known at compile time.
Object Safety§
This trait is not object safe.