Struct cpython::PyType [−][src]
pub struct PyType(_);
Represents a reference to a Python type object.
Methods
impl PyType[src]
impl PyTypepub fn as_type_ptr(&self) -> *mut PyTypeObject[src]
pub fn as_type_ptr(&self) -> *mut PyTypeObjectRetrieves the underlying FFI pointer associated with this Python object.
pub unsafe fn from_type_ptr(py: Python, p: *mut PyTypeObject) -> PyType[src]
pub unsafe fn from_type_ptr(py: Python, p: *mut PyTypeObject) -> PyTypeRetrieves 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]
pub fn name<'a>(&'a self, _py: Python<'a>) -> Cow<'a, str>Gets the name of the PyType.
pub fn is_subtype_of(&self, _: Python, b: &PyType) -> bool[src]
pub fn is_subtype_of(&self, _: Python, b: &PyType) -> boolReturn true if self is a subtype of b.
pub fn is_instance(&self, _: Python, obj: &PyObject) -> bool[src]
pub fn is_instance(&self, _: Python, obj: &PyObject) -> boolReturn 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]
pub fn call<A>(
&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 ToPyObject for PyType[src]
impl ToPyObject for PyTypeIdentity conversion: allows using existing PyObject instances where
T: ToPyObject is expected.
type ObjectType = PyType
fn to_py_object(&self, py: Python) -> PyType[src]
fn to_py_object(&self, py: Python) -> PyTypeConverts self into a Python object.
fn into_py_object(self, _py: Python) -> PyType[src]
fn into_py_object(self, _py: Python) -> PyTypeConverts self into a Python object. Read more
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R, [src]
fn with_borrowed_ptr<F, R>(&self, _py: Python, f: F) -> R where
F: FnOnce(*mut PyObject) -> R, Converts self into a Python object and calls the specified closure on the native FFI pointer underlying the Python object. Read more
impl<'source> FromPyObject<'source> for PyType[src]
impl<'source> FromPyObject<'source> for PyTypefn extract(py: Python, obj: &'source PyObject) -> PyResult<PyType>[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<PyType>Extracts Self from the source PyObject.
impl<'source> FromPyObject<'source> for &'source PyType[src]
impl<'source> FromPyObject<'source> for &'source PyTypefn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PyType>[src]
fn extract(py: Python, obj: &'source PyObject) -> PyResult<&'source PyType>Extracts Self from the source PyObject.
impl PythonObject for PyType[src]
impl PythonObject for PyTypefn as_object(&self) -> &PyObject[src]
fn as_object(&self) -> &PyObjectCasts the Python object to PyObject.
fn into_object(self) -> PyObject[src]
fn into_object(self) -> PyObjectCasts the Python object to PyObject.
unsafe fn unchecked_downcast_from(obj: PyObject) -> Self[src]
unsafe fn unchecked_downcast_from(obj: PyObject) -> SelfUnchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
ⓘImportant traits for &'a mut Runsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a Self[src]
unsafe fn unchecked_downcast_borrow_from<'a>(obj: &'a PyObject) -> &'a SelfUnchecked downcast from PyObject to Self. Undefined behavior if the input object does not have the expected type.
impl PythonObjectWithCheckedDowncast for PyType[src]
impl PythonObjectWithCheckedDowncast for PyTypefn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>[src]
fn downcast_from<'p>(
py: Python<'p>,
obj: PyObject
) -> Result<PyType, PythonObjectDowncastError<'p>>Cast from PyObject to a concrete Python object type.
fn downcast_borrow_from<'a, 'p>(
py: Python<'p>,
obj: &'a PyObject
) -> Result<&'a PyType, PythonObjectDowncastError<'p>>[src]
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.
impl PythonObjectWithTypeObject for PyType[src]
impl PythonObjectWithTypeObject for PyTypefn type_object(py: Python) -> PyType[src]
fn type_object(py: Python) -> PyTypeRetrieves the type object for this Python object type.
impl PartialEq for PyType[src]
impl PartialEq for PyTypefn eq(&self, o: &PyType) -> bool[src]
fn eq(&self, o: &PyType) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl Eq for PyType[src]
impl Eq for PyType