Struct cpython::PyType [−][src]
Represents a reference to a Python type object.
Implementations
impl PyType[src]
pub fn as_type_ptr(&self) -> *mut PyTypeObject[src]
Retrieves the underlying FFI pointer associated with this Python object.
pub unsafe fn from_type_ptr(py: Python<'_>, p: *mut PyTypeObject) -> PyType[src]
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.
pub fn name<'a>(&'a self, _py: Python<'a>) -> Cow<'a, str>[src]
Gets the name of the PyType.
pub fn is_subtype_of(&self, _: Python<'_>, b: &PyType) -> bool[src]
Return true if self is a subtype of b.
pub fn is_instance(&self, _: Python<'_>, obj: &PyObject) -> bool[src]
Return true if obj is an instance of self.
pub fn call<A>(
&self,
py: Python<'_>,
args: A,
kwargs: Option<&PyDict>
) -> PyResult<PyObject> where
A: ToPyObject<ObjectType = PyTuple>, [src]
&self,
py: Python<'_>,
args: A,
kwargs: Option<&PyDict>
) -> PyResult<PyObject> where
A: ToPyObject<ObjectType = PyTuple>,
Calls the type object, thus creating a new instance.
This is equivalent to the Python expression: self(*args, **kwargs)
Trait Implementations
impl Eq for PyType[src]
impl<'s> FromPyObject<'s> for PyType[src]
impl<'s> FromPyObject<'s> for &'s PyType[src]
impl PartialEq<PyType> for PyType[src]
impl PythonObject for PyType[src]
fn as_object(&self) -> &PyObject[src]
fn into_object(self) -> PyObject[src]
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self[src]
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self[src]
Unchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
impl PythonObjectWithCheckedDowncast for PyType[src]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>[src]
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyType, PythonObjectDowncastError<'p>>[src]
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyType, PythonObjectDowncastError<'p>>
impl PythonObjectWithTypeObject for PyType[src]
fn type_object(py: Python<'_>) -> PyType[src]
impl ToPyObject for PyType[src]
Identity conversion: allows using existing PyObject instances where
T: ToPyObject is expected.
type ObjectType = PyType
fn to_py_object(&self, py: Python<'_>) -> PyType[src]
fn into_py_object(self, _py: Python<'_>) -> PyType[src]
fn with_borrowed_ptr<F, R>(&self, _py: Python<'_>, f: F) -> R where
F: FnOnce(*mut PyObject) -> R, [src]
F: FnOnce(*mut PyObject) -> R,
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
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,