Struct cpython::PyType[][src]

pub struct PyType(_);

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]

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]

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]

impl PythonObjectWithTypeObject for PyType[src]

impl ToPyObject for PyType[src]

Identity conversion: allows using existing PyObject instances where T: ToPyObject is expected.

type ObjectType = PyType

Auto Trait Implementations

impl RefUnwindSafe for PyType[src]

impl Send for PyType[src]

impl Sync for PyType[src]

impl Unpin for PyType[src]

impl UnwindSafe for PyType[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.